Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
20
Task/Loops-While/JavaScript/loops-while-2.js
Normal file
20
Task/Loops-While/JavaScript/loops-while-2.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
function loopWhile(varValue, fnDelta, fnTest) {
|
||||
'use strict';
|
||||
var d = fnDelta(varValue);
|
||||
|
||||
return fnTest(d) ? [d].concat(
|
||||
loopWhile(d, fnDelta, fnTest)
|
||||
) : [];
|
||||
}
|
||||
|
||||
console.log(
|
||||
loopWhile(
|
||||
1024,
|
||||
function (x) {
|
||||
return Math.floor(x/2);
|
||||
},
|
||||
function (x) {
|
||||
return x > 0;
|
||||
}
|
||||
).join('\n')
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue