Skip to content

Instantly share code, notes, and snippets.

View zonayedpca's full-sized avatar
:octocat:
Coffee, Coke, Code

Zonayed Ahmed zonayedpca

:octocat:
Coffee, Coke, Code
View GitHub Profile
@zonayedpca
zonayedpca / dowhile.js
Last active March 24, 2018 15:48
Do While Loop
var num;
do {
console.log('Inside the Loop');
num = prompt('Enter the number: ');
} while(num < 10);
console.log('Outside the Loop');
@zonayedpca
zonayedpca / whileloop2.js
Created March 24, 2018 15:57
While Loop 2
var num = 20;
while(num < 10) {
console.log('Inside the Loop');
num = prompt('Enter the number: ');
}
console.log('Out of the loop');
for(var i = 0; i < 10; i++) {
if(i === 5) {
break;
}
console.log('i is now at: ' + i);
}
for(var i = 0; i < 10; i++) {
if(i === 5) {
console.log(i + ' is skipped');
continue;
}
console.log('i is now at: ' + i);
}
@zonayedpca
zonayedpca / forinloop.js
Created March 24, 2018 16:12
For In Loop
var items = [1, 2, 3, 4, 5, 6];
for(item in items) {
console.log(item);
}
@zonayedpca
zonayedpca / withoutMap.js
Last active March 25, 2018 05:12
Without Map
var items = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var anotherItems = [];
for(var i = 0; i < items.length; i++) {
anotherItems.push(items[i] * 2);
}
console.log(anotherItems);
@zonayedpca
zonayedpca / withMap.js
Last active March 25, 2018 05:13
With Map
var items = [1, 2, 3, 4, 5, 6, 7, 8, 9];
var anotherItems = items.map(function(item) {
return item * 2;
});
console.log(anotherItems);
@zonayedpca
zonayedpca / withMapES6.js
Last active March 25, 2018 05:14
With Map ES6
const items = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const anotherItems = items.map(item => item * 2);
console.log(anotherItems);
@zonayedpca
zonayedpca / function.js
Created March 29, 2018 16:52
Basic Function
function funcName() {
console.log('Hello I am from the function');
}
funcName();
@zonayedpca
zonayedpca / function.js
Created March 29, 2018 16:54
Basic Function
var funcName = function() {
console.log('Hello I am from the function');
}
funcName();