Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
5
Task/Loops-While/JavaScript/loops-while-1.js
Normal file
5
Task/Loops-While/JavaScript/loops-while-1.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
var n = 1024;
|
||||
while (n > 0) {
|
||||
print(n);
|
||||
n /= 2;
|
||||
}
|
||||
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')
|
||||
);
|
||||
10
Task/Loops-While/JavaScript/loops-while-3.js
Normal file
10
Task/Loops-While/JavaScript/loops-while-3.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
512
|
||||
256
|
||||
128
|
||||
64
|
||||
32
|
||||
16
|
||||
8
|
||||
4
|
||||
2
|
||||
1
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
var n = 1024;
|
||||
while (n>0) {
|
||||
print(n);
|
||||
n/=2;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue