mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-07-15 20:53:20 +09:00
remove timer and simon
This commit is contained in:
+24
-19
@@ -1,32 +1,37 @@
|
||||
function add () {
|
||||
|
||||
function add(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
function subtract () {
|
||||
|
||||
function subtract(a, b) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
function sum () {
|
||||
|
||||
function sum(array) {
|
||||
return array.reduce((current, total) => total + current, 0);
|
||||
}
|
||||
|
||||
function multiply () {
|
||||
|
||||
function multiply(array) {
|
||||
return array.reduce((current, total) => total * current, 1);
|
||||
}
|
||||
|
||||
function power() {
|
||||
|
||||
function power(a, b) {
|
||||
return Math.pow(a, b);
|
||||
}
|
||||
|
||||
function factorial() {
|
||||
|
||||
function factorial(n) {
|
||||
if (n == 0) return 0;
|
||||
let product = 1;
|
||||
for (let i = n; i > 0; i--) {
|
||||
product *= i;
|
||||
}
|
||||
return product;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
add,
|
||||
subtract,
|
||||
sum,
|
||||
multiply,
|
||||
power,
|
||||
factorial
|
||||
}
|
||||
add,
|
||||
subtract,
|
||||
sum,
|
||||
multiply,
|
||||
power,
|
||||
factorial
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user