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)
相关推荐
若兰幽竹9 分钟前
【机器学习】多元线性回归算法和正规方程解求解
算法·机器学习·线性回归
鱼力舟23 分钟前
【hot100】240搜索二维矩阵
算法
北_鱼2 小时前
支持向量机(SVM):算法讲解与原理推导
算法·机器学习·支持向量机
MZWeiei3 小时前
PTA:运用顺序表实现多项式相加
算法
GISer_Jing4 小时前
Javascript排序算法(冒泡排序、快速排序、选择排序、堆排序、插入排序、希尔排序)详解
javascript·算法·排序算法
cookies_s_s4 小时前
Linux--进程(进程虚拟地址空间、页表、进程控制、实现简易shell)
linux·运维·服务器·数据结构·c++·算法·哈希算法
不想编程小谭4 小时前
力扣LeetCode: 2506 统计相似字符串对的数目
c++·算法·leetcode
水蓝烟雨4 小时前
[HOT 100] 2187. 完成旅途的最少时间
算法·hot 100
菜鸟一枚在这5 小时前
深度解析建造者模式:复杂对象构建的优雅之道
java·开发语言·算法
gyeolhada6 小时前
2025蓝桥杯JAVA编程题练习Day5
java·数据结构·算法·蓝桥杯