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")
相关推荐
翊谦8 小时前
Java Agent开发 Milvus 向量数据库安装
java·数据库·milvus
晓晓hh8 小时前
JavaSE学习——迭代器
java·开发语言·学习
查古穆8 小时前
栈-有效的括号
java·数据结构·算法
kyriewen118 小时前
你点的“刷新”是假刷新?前端路由的瞒天过海术
开发语言·前端·javascript·ecmascript·html5
Java面试题总结8 小时前
Spring - Bean 生命周期
java·spring·rpc
硅基诗人9 小时前
每日一道面试题 10:synchronized 与 ReentrantLock 的核心区别及生产环境如何选型?
java
014-code9 小时前
String.intern() 到底干了什么
java·开发语言·面试
摇滚侠9 小时前
JAVA 项目教程《苍穹外卖-12》,微信小程序项目,前后端分离,从开发到部署
java·开发语言·vue.js·node.js
楚国的小隐士9 小时前
为什么说Rust是对自闭症谱系人士友好的编程语言?
java·rust·编程·对比·自闭症·自闭症谱系障碍·神经多样性
Timer@10 小时前
LangChain 教程 04|Agent 详解:让 AI 学会“自己干活“
javascript·人工智能·langchain