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
var x = 1; | |
console.log(x++); | |
// x++ will increment the number | |
// after it has been printed (any operation) | |
// which means x will only be incremented after the | |
// above statement is executed | |
// value of x after line number 2 is executed is 2 | |
console.log(++x); | |
// ++x will first increment and then | |
// print (or let it be used for operations) |
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
var classNumber = 1; // Initializaiton | |
while(classNumber <= 12) { // Declared a condition | |
console.log(classNumber); | |
classNumber++; // Updating the state | |
// which is moving the student from class | |
// number X to X+1 | |
} |
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
var x = 2; // Initialization | |
while(x <= 100) { // Condition | |
if(x % 2 == 0) { // % gives the remainder | |
// this means that the number | |
// is EVEN | |
console.log(x); | |
} | |
x = x + 1; // Updating the state | |
} |
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
var manojStudent = { | |
'name': 'manoj', | |
'age': 17, | |
'city': 'udaipur', | |
'class': '1st semster of college', | |
'weight': 55.67 | |
} | |
console.log(manojStudent); |
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
var manojStudent = { | |
'name': 'manoj', | |
'age': 17, | |
'city': 'udaipur', | |
'class': '1st semster of college', | |
'weight': 55.67 | |
} | |
console.log(manojStudent['age']); | |
console.log(manojStudent['weight']); |
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
var manojStudent = { | |
'name': 'manoj', | |
'age': 17, | |
'city': 'udaipur', | |
'class': '1st semster of college', | |
'weight': 55.67 | |
} | |
for(var nameOfKey in manojStudent) { | |
console.log(nameOfKey, "..", manojStudent[nameOfKey]); |
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
var topNStudents = [ | |
'manoj', | |
'ramesh', | |
'garima', | |
'ashish', | |
'saru', | |
'tanya' | |
]; |
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
var classTimes = [ | |
[8, 9, 8, 9], // Day 1 | |
[1, 2, 6, 7], // Day 2 | |
[2, 7, 8, 9] // Day 3 | |
] | |
console.log(classTimes[1]); | |
console.log(classTimes[1][0]); |
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 person = { | |
firstName: "..", | |
lastName: '..', | |
age: 30 | |
} | |
console.log(person['age']); | |
// We want to modify the age | |
for(var nameOfKey in person) { | |
if(nameOfKey == "age") { // If the name of key is age | |
// If the key is age, |
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
var firstName = "foo"; | |
var lastName = "bar"; | |
var fullName = firstName + " " + lastName; | |
console.log(fullName); | |
var _fullName = `${firstName} ${lastName}`; // concatenate strings | |
console.log(_fullName); |