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")
相关推荐
蓝婷儿12 分钟前
第二章:CSS秘典 · 色彩与布局的力量
前端·css
flying robot14 分钟前
js在浏览器执行原理
开发语言·javascript·ecmascript
Wyc724091 小时前
HTML:入门
前端·html
Sunny_lxm1 小时前
自定义列甘特图,原生开发dhtmlxgantt根特图,根据数据生成只读根特图,页面展示html demo
前端·html·甘特图·dhtmlxgantt
熊猫钓鱼>_>2 小时前
建筑IT数字化突围:建筑设计企业的生存法则重塑
前端·javascript·easyui
代码小将2 小时前
Leetcode209做题笔记
java·笔记·算法
专注_每天进步一点点2 小时前
idea 启动Springboot项目在编译阶段报错:java: OutOfMemoryError: insufficient memory
java·spring boot·intellij-idea
dhxhsgrx3 小时前
PYTHON训练营DAY25
java·开发语言·python
GISer_Jing4 小时前
前端性能指标及优化策略——从加载、渲染和交互阶段分别解读详解并以Webpack+Vue项目为例进行解读
前端·javascript·vue
不知几秋4 小时前
数字取证-内存取证(volatility)
java·linux·前端