0001【Edabit ★☆☆☆☆☆】【两数之和】Return the Sum of Two Numbers

Return the Sum of Two Numbers

algebra math numbers

Instructions

Create a function that takes two numbers as arguments and returns their sum.

Examples
javascript 复制代码

addition(3, 2) // 5

addition(-3, -6) // -9

addition(7, 3) // 10

Notes
  • Don't forget to return the result.
Solutions
javascript 复制代码
const addition = (a, b) => a+b;
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);
            }
        }
    }
})();

Test.assertEquals(addition(2, 3), 5)
Test.assertEquals(addition(-3, -6), -9)
Test.assertEquals(addition(7, 3), 10)
Test.assertEquals(addition(88, 2), 90)
相关推荐
NEFU_Jyj7 小时前
贝尔数(组合数学)
算法
希和20278 小时前
C语言程序设计题|有序数组插入数字冒泡排序
c语言·数据结构·算法
Pniubi8 小时前
力扣73 矩阵置零
算法·leetcode·矩阵
布莱克60518 小时前
C++ 中 map 的 insert 与 emplace:key 已存在时会覆盖吗?
开发语言·数据结构·c++·算法·map
D e re k ZH21 小时前
C++ 系统学习手记:从语法细节到工程实践
开发语言·数据结构·c++·算法
石小石Orz1 天前
AI 正在蚕食我们的编码能力
前端·后端·算法
民乐团扒谱机1 天前
【微实验】NSGA-II(非支配排序遗传算法)——解决多目标优化问题的“自然选择模拟器”
linux·人工智能·算法
青少儿编程课堂1 天前
蓝桥杯·全国青少年信息素养大赛·电子学会Python/C++考级:中缀表达式求值解析
c++·python·算法·bfs·信息学竞赛
武子康1 天前
Qwen-Drive 到底是什么:4B 级 VLM 如何成为驾驶策略底座
人工智能·算法·机器学习