0031【Edabit ★☆☆☆☆☆】【使用箭头函数】Using Arrow Functions

0031【Edabit ★☆☆☆☆☆】【使用箭头函数】Using Arrow Functions

data_structures language_fundamentals

Instructions

Create a function that returns the given argument, but by using an arrow function.

An arrow function is constructed like so:

javascript 复制代码
arrowFunc=(/*parameters*/)=>//code here
Examples
javascript 复制代码
arrowFunc(3) // 3
arrowFunc("3") // "3"
arrowFunc(true) // true
Notes
  • N/A
Solutions
javascript 复制代码
// create your arrow function below
arrowFunc = (parameter) => parameter ;
TestCases
javascript 复制代码
let Test = (function(){
    return {
        assertEquals:function(actual,expected){
            if(actual !== expected){
                let errorMsg = `actual is ${actual},${expected} is expected`;
                throw new Error(errorMsg);
            }
        }
    }
})();


if(!(String(arrowFunc).includes('=>'))){
    Test.assertEquals(0,1,"Your code does not use an arrow function")
}

Test.assertEquals(arrowFunc(3),3)
Test.assertEquals(arrowFunc("3"),"3")
Test.assertEquals(arrowFunc(true),true)
Test.assertEquals(arrowFunc("test"),"test")
相关推荐
啃火龙果的兔子2 分钟前
JDK 安装配置
java·开发语言
星哥说事2 分钟前
应用程序监控:Java 与 Web 应用的实践
java·开发语言
派大鑫wink8 分钟前
【JAVA学习日志】SpringBoot 参数配置:从基础到实战,解锁灵活配置新姿势
java·spring boot·后端
我是小路路呀20 分钟前
element级联选择器:已选中一个二级节点,随后又点击了一个一级节点(仅浏览,未确认选择),此时下拉框失去焦点并关闭
javascript·vue.js·elementui
程序员爱钓鱼26 分钟前
Node.js 编程实战:文件读写操作
前端·后端·node.js
xUxIAOrUIII31 分钟前
【Spring Boot】控制器Controller方法
java·spring boot·后端
PineappleCoder34 分钟前
工程化必备!SVG 雪碧图的最佳实践:ID 引用 + 缓存友好,无需手动算坐标
前端·性能优化
Dolphin_Home34 分钟前
从理论到实战:图结构在仓库关联业务中的落地(小白→中级,附完整代码)
java·spring boot·后端·spring cloud·database·广度优先·图搜索算法
醇氧36 分钟前
org.jetbrains.annotations的@Nullable 学习
java·开发语言·学习·intellij-idea
Java&Develop38 分钟前
Aes加密 GCM java
java·开发语言·python