const neverChange = "Project Key"; // comment
let oftenChanges = 0; // maybe we will change this value later
var oldDeclaration = 0; // we try to avoid using var now; use let instead
let first="Matt";
let last="Price"
console.log(first + last);
Do it w/ your name!
let n = 1,
m=2,
s="Hello, there! ";
console.log(m+n);
console.log(s+n);
let historians= ["Edward Gibbon", "Leopold von Ranke", "Edward Said", "Joan Scott"];
undefined
a = [];
a.push("Edward Gibbon");
a.push("Edward Said");
a.push("Joan Scott");
console.log(a[1]);
a.pop();
// a
wardates=[1776, 1792, 1812, 1861, 1870, 1914, 1939, 1994]
console.log("The time between The First and \
Second World Wars was " + (wardates[6] - wardates[5]) + " years");
let historians= ["Edward Gibbon", "Leopold von Ranke", "Edward Said", "Joan Scott"];
let i = 0;
while (i < historians.length) {
console.log(historians[i] + " was a historian.");
i+=1;
}
repeat inside the { ... }
as long as test is true:
let historians= ["Edward Gibbon", "Leopold von Ranke", "Edward Said", "Joan Scott"];
for (let i=0; i < historians.length ; i++){
console.log(historians[i] + " was a historian.");
i // this is not required, just here to show you a slight difference
}
let historians= ["Edward Gibbon", "Leopold von Ranke", "Edward Said", "Joan Scott"];
for (i in historians) {
console.log(historians[i] + " was a historian.");
}
for (let h of historians) {
console.log(h + " was a historian.");
}
let historians= ["Edward Gibbon", "Leopold von Ranke", "Edward Said", "Joan Scott"];
let i = 0;
while (i < historians.length) {
if (historians[i] === "Joan Scott") {
console.log(historians[i] + " is my favourite.");
}
i +=1;
};
let historians= ["Edward Gibbon", "Leopold von Ranke", "Edward Said", "Joan Scott"];
let i = 0;
while (i < historians.length) {
if (historians[i] ==="Joan Scott") {
console.log(historians[i] + " is my favourite.");
} else {
console.log(historians[i] + ", meh.");
}
i +=1;
};