Created
May 16, 2019 11:51
-
-
Save yashuvit89/cd5e0ff68c77ba2e64f6eb8f237c82a7 to your computer and use it in GitHub Desktop.
JS Bin [Komprise] // source https://jsbin.com/futarak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="[Komprise]"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<h2>Komprise Telephonic</h2> | |
<ul> | |
<li> | |
SetTimeout - loop | |
<pre> | |
for (var i = 1; i <= 10; i++) { | |
((x)=> { | |
console.log(x) | |
if(x > 7) { | |
setTimeout(() => console.log(x), 500); | |
} | |
if(x === 1) setTimeout(() => console.log(x), 50); | |
if(x < 2) setTimeout(() => console.log(x), 100); | |
})(i) | |
} | |
</pre> | |
</li> | |
<li> | |
Write program of x%y without modulo | |
</li> | |
<li> | |
Print recursive labels in nested array of objects of any depth | |
</li> | |
</ul> | |
<script id="jsbin-javascript"> | |
// What this program prints | |
// abel: "Audi", | |
//test | |
/* | |
for (i = 1 to 10) { | |
console.log(i) | |
if(i>7) sto(console.log(i), 500) | |
if(i === 1) sto(log(i), 50) | |
if(i < 2) sto(log(i), 100) | |
} | |
*/ | |
sto => 10 | |
1 to 10 | |
10 | |
10 | |
10 | |
10 | |
10 | |
// TEST | |
for (i = 1 to 10) { | |
(function(x){ | |
console.log(x) | |
if(x>7) sto(console.log(x), 500) | |
if(x === 1) sto(log(x), 50) | |
if(x < 2) sto(log(x), 100) | |
})(i) | |
} | |
sto => exact number | |
1 to 10 | |
1 | |
1 | |
8 | |
9 | |
10 | |
Output | |
--- | |
1 to 10 | |
8, 9, 10 | |
setTimeout(()=>{}, 500, param) | |
// Write function | |
/* | |
2. | |
x % y | |
*/ | |
function modulo(x, y) { | |
console.log(x, y) | |
// break condition | |
if () { | |
} | |
return modulo(x,y)/y | |
} | |
/* | |
[data = { | |
label:"Merc", | |
children: [ | |
{ | |
label: "Sedan", | |
children: [" | |
{ | |
label:"350D", | |
}, | |
{ | |
label:"500D" | |
} | |
}, | |
{ | |
label: "SUV", | |
children: "{label:"GLA350"} } | |
] | |
}, | |
llabel:"Audi", | |
children: [ | |
{ | |
label: "Sedan", | |
children: [{label:"A3"}, {label:"A5"}] | |
}, | |
{ | |
label: "SUV", | |
children: [{label:"Q3"}] | |
} | |
] | |
} | |
] | |
*/ | |
[ | |
{ | |
label | |
children | |
} | |
] | |
// Print nested labels | |
function printLabel(arr) { | |
for(var i=0; i < arr.length; i++) { | |
var currObj = arr[i]; | |
if (currObj['label']) { | |
console.log(currObj['label']); | |
} | |
var children = arr[children]; | |
if (children && children.length > 0) { | |
printLable(children); | |
} | |
} | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript"> | |
// What this program prints | |
// abel: "Audi", | |
//test | |
/* | |
for (i = 1 to 10) { | |
console.log(i) | |
if(i>7) sto(console.log(i), 500) | |
if(i === 1) sto(log(i), 50) | |
if(i < 2) sto(log(i), 100) | |
} | |
*/ | |
sto => 10 | |
1 to 10 | |
10 | |
10 | |
10 | |
10 | |
10 | |
// TEST | |
for (i = 1 to 10) { | |
(function(x){ | |
console.log(x) | |
if(x>7) sto(console.log(x), 500) | |
if(x === 1) sto(log(x), 50) | |
if(x < 2) sto(log(x), 100) | |
})(i) | |
} | |
sto => exact number | |
1 to 10 | |
1 | |
1 | |
8 | |
9 | |
10 | |
Output | |
--- | |
1 to 10 | |
8, 9, 10 | |
setTimeout(()=>{}, 500, param) | |
// Write function | |
/* | |
2. | |
x % y | |
*/ | |
function modulo(x, y) { | |
console.log(x, y) | |
// break condition | |
if () { | |
} | |
return modulo(x,y)/y | |
} | |
/* | |
[data = { | |
label:"Merc", | |
children: [ | |
{ | |
label: "Sedan", | |
children: [" | |
{ | |
label:"350D", | |
}, | |
{ | |
label:"500D" | |
} | |
}, | |
{ | |
label: "SUV", | |
children: "{label:"GLA350"} } | |
] | |
}, | |
llabel:"Audi", | |
children: [ | |
{ | |
label: "Sedan", | |
children: [{label:"A3"}, {label:"A5"}] | |
}, | |
{ | |
label: "SUV", | |
children: [{label:"Q3"}] | |
} | |
] | |
} | |
] | |
*/ | |
[ | |
{ | |
label | |
children | |
} | |
] | |
// Print nested labels | |
function printLabel(arr) { | |
for(var i=0; i < arr.length; i++) { | |
var currObj = arr[i]; | |
if (currObj['label']) { | |
console.log(currObj['label']); | |
} | |
var children = arr[children]; | |
if (children && children.length > 0) { | |
printLable(children); | |
} | |
} | |
} | |
</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// What this program prints | |
// abel: "Audi", | |
//test | |
/* | |
for (i = 1 to 10) { | |
console.log(i) | |
if(i>7) sto(console.log(i), 500) | |
if(i === 1) sto(log(i), 50) | |
if(i < 2) sto(log(i), 100) | |
} | |
*/ | |
sto => 10 | |
1 to 10 | |
10 | |
10 | |
10 | |
10 | |
10 | |
// TEST | |
for (i = 1 to 10) { | |
(function(x){ | |
console.log(x) | |
if(x>7) sto(console.log(x), 500) | |
if(x === 1) sto(log(x), 50) | |
if(x < 2) sto(log(x), 100) | |
})(i) | |
} | |
sto => exact number | |
1 to 10 | |
1 | |
1 | |
8 | |
9 | |
10 | |
Output | |
--- | |
1 to 10 | |
8, 9, 10 | |
setTimeout(()=>{}, 500, param) | |
// Write function | |
/* | |
2. | |
x % y | |
*/ | |
function modulo(x, y) { | |
console.log(x, y) | |
// break condition | |
if () { | |
} | |
return modulo(x,y)/y | |
} | |
/* | |
[data = { | |
label:"Merc", | |
children: [ | |
{ | |
label: "Sedan", | |
children: [" | |
{ | |
label:"350D", | |
}, | |
{ | |
label:"500D" | |
} | |
}, | |
{ | |
label: "SUV", | |
children: "{label:"GLA350"} } | |
] | |
}, | |
llabel:"Audi", | |
children: [ | |
{ | |
label: "Sedan", | |
children: [{label:"A3"}, {label:"A5"}] | |
}, | |
{ | |
label: "SUV", | |
children: [{label:"Q3"}] | |
} | |
] | |
} | |
] | |
*/ | |
[ | |
{ | |
label | |
children | |
} | |
] | |
// Print nested labels | |
function printLabel(arr) { | |
for(var i=0; i < arr.length; i++) { | |
var currObj = arr[i]; | |
if (currObj['label']) { | |
console.log(currObj['label']); | |
} | |
var children = arr[children]; | |
if (children && children.length > 0) { | |
printLable(children); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment