-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathmy-script.js
More file actions
88 lines (66 loc) · 2.4 KB
/
my-script.js
File metadata and controls
88 lines (66 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/***********************************
* Add your functions in this file
*
* You can test your functions by running `npm test`
* in your terminal in this directory. It will watch
* for changes and check for correctness.
*
* For an example, you get the first for free!
*/
/**
* Write a function called `greeting` that returns the string `Hello, <name>!`
* where <name> is passed to the function as an argument
*/
const greeting = (name) => {
return `Hello, ${name}!`;
};
/**
* Write a function called `add` that returns the sum of two numbers
*/
/**
* Write a function called `subtract` that returns the difference between two numbers
*/
/**
* Write a function called `min` that returns the smaller of two numbers
*/
/**
* Write a function called `max` that returns the larger of two numbers
*/
/**
* Write a function called `isEven` that takes a single value and
* returns `true` if it is even and `false` if it is odd
*/
/**
* Write a function called `isOdd` that takes a single value and
* returns `false` if it is even and `true` if it is odd
*/
/**
* Write a function called `factorial` that takes a single integer and
* returns the product of the integer and all the integers below it
*/
/**
* Write a function called `oddFactorial` that takes a single integer and
* returns the product of the integer and all the integers below it, but
* only if they are odd. If the starting number is even, don't include it.
*/
/**
* Write a function that solves the Chessboard exercise from chapter two,
* https://eloquentjavascript.net/02_program_structure.html#i_swb9JBtSQQ
* Instead of printing each line using `console.log()`, build the grid using
* a single string and return it at the end of the function
*/
/*******************************************
* DO NOT CHANGE ANYTHING BELOW THIS LINE!
*/
module.exports = {
greeting: typeof greeting === 'function' ? greeting : null,
add: typeof add === 'function' ? add : null,
subtract: typeof subtract === 'function' ? subtract : null,
min: typeof min === 'function' ? min : null,
max: typeof max === 'function' ? max : null,
isEven: typeof isEven === 'function' ? isEven : null,
isOdd: typeof isOdd === 'function' ? isOdd : null,
factorial: typeof factorial === 'function' ? factorial : null,
oddFactorial: typeof oddFactorial === 'function' ? oddFactorial : null,
chessboard: typeof chessboard === 'function' ? chessboard : null,
};