forked from truecodersio/JavaScript_HOF
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
23 lines (17 loc) · 914 Bytes
/
app.js
File metadata and controls
23 lines (17 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
console.log("Hello World!\n==========\n");
// Exercise 1 Section
console.log("EXERCISE 1:\n==========\n");
// - Write a function that takes in a number parameter and returns a function that adds the number parameter with a new number parameter.
// 1. Declare a function `plus` that takes in a `number` parameter.
// 2. Inside the body of `plus`, use the `return` keyword to return an anonymous function
// 3. The return function will take in a `plusNumber` parameter, and return the value of `plusNumber` with the first parameter `number`
// 4. Next, declare a variable `plus15` that is assigned the value of `plus` with 15 passed in
// 5. `console.log` the result of `plus15` with 10 passed in
// End result should resemble: `console.log(plus15(10)) // Outputs 25`
function plus(number) {
return function (plusNumber) {
return plusNumber + number;
}
}
let plus15 = plus(15);
console.log(plus15(10));