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)
相关推荐
Allen Wurlitzer14 分钟前
算法刷题记录——LeetCode篇(1.9) [第81~90题](持续更新)
算法·leetcode·职场和发展
@MrLiu16 分钟前
# 深度学习中的优化算法详解
人工智能·深度学习·算法·优化器
阳洞洞19 分钟前
leetcode 377. Combination Sum IV
算法·leetcode·动态规划·完全背包问题
阿巴~阿巴~1 小时前
蓝桥杯 C/C++ 组历届真题合集速刷(一)
c语言·c++·算法·蓝桥杯
_x_w1 小时前
【12】数据结构之基于线性表的排序算法
开发语言·数据结构·笔记·python·算法·链表·排序算法
瀚海澜生1 小时前
链表系列入门指南(二):吃透这几题,链表解题不再难
后端·算法
爱编码的傅同学1 小时前
数据结构(五)——AVL树(平衡二叉搜索树)
数据结构·算法
Bonnie_12151 小时前
02-redis-数据结构实现原理
数据结构·redis·算法
Wood_Like2 小时前
从递归入手一维动态规划
算法·动态规划
爱奥尼欧3 小时前
算法竞赛中常用的数据处理库函数
算法