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")
相关推荐
RainbowSea1 天前
12. LangChain4j + 向量数据库操作详细说明
java·langchain·ai编程
RainbowSea1 天前
11. LangChain4j + Tools(Function Calling)的使用详细说明
java·langchain·ai编程
excel1 天前
为什么在 Three.js 中平面能产生“起伏效果”?
前端
excel1 天前
Node.js 断言与测试框架示例对比
前端
天蓝色的鱼鱼1 天前
前端开发者的组件设计之痛:为什么我的组件总是难以维护?
前端·react.js
codingandsleeping1 天前
使用orval自动拉取swagger文档并生成ts接口
前端·javascript
考虑考虑1 天前
Jpa使用union all
java·spring boot·后端
石金龙1 天前
[译] Composition in CSS
前端·css
用户3721574261351 天前
Java 实现 Excel 与 TXT 文本高效互转
java
白水清风1 天前
微前端学习记录(qiankun、wujie、micro-app)
前端·javascript·前端工程化