Made by Antonija with
#9 borders:none
alert("Hello from javascript file");
add this code...
var word;
// expression
console.log(word)
// undefined
var word = "Sunshine";
// statement
console.log(word)
=> "Sunshine"
// word changed from undefined to "Sunshine"
console.log(x)
var x = 2;
=> undefined
var x = "my new value";
console.log(x)
=> "my new value";
console.log(x)
let x = 2;
=> ReferenceError, x is not defined
let x = 3;
=> SyntaxError, Identifier 'x' has already been declared
let x = 5
console.log(x)
=> 5
console.log(x)
const x = 2;
=> ReferenceError, x is not defined
const x = 3;
=> SyntaxError, Identifier 'x' has already been declared
const x = "My new value";
=> Uncaught TypeError: Assignment to constant variable.
var a = [1,2,3,4];
a.unshift(0);
var a = [1,2,3,4];
a.push(5);
var a = [1,2,3,4];
a.shift();
var a = [1,2,3,4];
a.pop();
typeof "Hello" => "string"
typeof 2 => "number"
typeof true => "boolean"
typeof [1,2,3,4] => "object"
+, -, /, %
console.log("My name is " + firstName + " I am" + age);
let balloonsCount = 100;
console.log(`We have ${balloonsCount} balloons!`);
let petName = "Furry";
console.log(`I have a pet! Its name is ${petName}`);
let euroEarned = 100;
console.log(`I earned ${euroEarned * 7.4} kuna`);
console.log(firstVariable + secondVariable);
var thirdVariable = numberOne % numberTwo;
3 % 12 // zero times with 3 left over.
var a = 5;
a += 5;
// same as a + a
// 10
var a = 10;
a -= 5;
// same as a - a
// 5
if (condition1) {
// block of code to be executed if condition1 is true
} else if (condition2) {
// block of code to be executed if the condition1 is false and condition2 is true
} else {
// block of code to be executed if the condition1 is false and condition2 is false
}
You are a bouncer at the club, and only real grownups can get in. Use JS to check who is an adult.
var i = 0;
while (i < 10) {
console.log(i)
i++;
}
var i;
for (i = 0; i < array.length; i++) {
console.log(array[i]);
}
function sayHello () {
console.log("Hello");
};
sayHello();
function sayMyName (name) {
console.log(`Hello ${name}`);
};
sayMyName("Antonija");
isEvenInt(4) => "4 is even number"
isEvenInt(9) => "9 is not even number"
isEvenInt("banana") => "banana is not a valid type"
Finished before the others? Write a function that will check if any number is even/odd, not just integers
Object oriented programming (OOP)
var person = {
};
var person = {
name: "Antonija",
city: "Zagreb",
hobbies: ["basketball", "hiking", "sleeping"]
};
console.log(person.name + person.city)
person.favMovie = "Kill Bill";
console.log(person);
person.name = "Anthony";
console.log(person.name);
person.name = "Anthony";
delete person.name;
console.log(person);
let person = {
name: "Ant",
location: "Zagreb",
brothers: 1,
sisters: 2
}
for (let key in person) {
console.log(`${key}: + ${person[key]}`)
}