-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOwnLoop.js
More file actions
26 lines (19 loc) · 874 Bytes
/
OwnLoop.js
File metadata and controls
26 lines (19 loc) · 874 Bytes
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
/* write a higher function loop that provides something like a for loop statement. it takes a value, a test function, an update function, and a body and stops if that returns false. Then it calls the body function, giving it the current value. Finally, it calls the update function to create a new value and starts from the beginning. */
function test(greeting) {
"use strict";
if (greeting != undefined) {
function body(currentvalue) {
currentvalue = greeting;
return update("kevin");
function update(name) {
var newValue = `${greeting} ${name}`;
return newValue;
}
}
// console.log(greeting);
// console.log(body());
return body();
} else return false;
}
console.log(test('hello'))
// test("hello");