This file contains hidden or 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
for (var i = 0; i < 10; i++) { | |
setTimeout(() => { | |
console.log(`The number is ${i}`); | |
}, 1000); | |
} |
This file contains hidden or 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
for (var i = 0; i < 10; i++) { | |
(function () { | |
var currentValueOfI = i; | |
setTimeout(() => { | |
console.log(`The number is ${currentValueOfI}`); | |
}, 1000); | |
})(); | |
} |
false == "0" // true
// false gets coerced to 0
// "0" gets coerced to 0
// 0 == 0 is true
false == 0 // true
// false gets coerced to 0
// 0 == 0 is true
This file contains hidden or 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
function calculateBill(total, tax, tip) { | |
return total + total * tax + total * tip; | |
} | |
var result = calculateBill(100, 0.13, 0.15); | |
console.log(result); |
This file contains hidden or 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
function calculateMyBill(total, tax, tip) { | |
return total + total * tax + total * tip; | |
} | |
var result = calculateMyBill(100); | |
console.log(result); |
This file contains hidden or 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
function calculateBill(total, tax = 0.13, tip = 0.15) { | |
return total + total * tax + total * tip; | |
} | |
const result = calculateBill(100); | |
console.log(result); |
This file contains hidden or 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
function addNumber(num1, num2 = 20, num3 = 10) { | |
return num1 + num2 + num3; | |
} | |
console.log(addNumber(10)); | |
console.log(addNumber(10, 40, 30)); |
This file contains hidden or 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
const names = ["sakib", "tamim", "Riad"]; | |
const fullNames = names.map(function(name) { | |
return `${name}`; | |
}); | |
console.log(fullNames); |
This file contains hidden or 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
const names = ["sakib", "tamim", "Riad"]; | |
const fullNames = names.map(name => { | |
return `${name}`; | |
}); | |
console.log(fullNames); |
OlderNewer