Dynamic learning community for tech
Interactivity
Animation
Basically anything interesting
var function {} ; '' ""or
- keyword to declare a variable
- keyword to declare a function
- curly brackets
- terminator, signifies end of an argument
- string literal
= == === //- assignment
- equality with type coercion
- strict equality
- comment
console.log()- method to print data
true 'this is a string' 42 undefined- Boolean
falseor
null- String
- Number
- Nonvalue
- Nonvalue
- Denote missing info
var favoriteNumber = 8; var inventorOfFirstLanguageCompiler = 'Grace Hopper'; var whereaboutsOfBigFoot = undefined; var interestInTheKardashians = false;// Only values you can use:
// Your first name
// Your last name
// The number 2
console.log(answer)
// Result:
// Hi there, my name is Dize Hacioglu
// and I know that 2 + 2 = 4. function sayHello() {
console.log('Hello!')
} sayHello function sayHello(name) {
console.log('Hello, ' + name + '!');
} sayHello(); sayHello('Adele'); // Hello, undefined! // Hello, Adele! function add(a, b) {
return a + b;
} add(2, 2) // 4function keyword
name of function
parameters
return statement (aka output)
arguments
var add = function(a, b) {
return a + b;
} add(2, 2) // 4// Write a function that accepts two parameters
// and always returns a message
// saying the first argument is cooler.
whoIsCooler('me', 'you');
// Output:
// Me is cooler than you!If...then logic
if(true) {
// do something
}If you spend $100 or more, then you get 20% off.
var total = 162;
if(total is greater than 100) {
// take 20% off the total
}If you spend $100 or more, then you get 20% off.
Otherwise, you get 5% off.
var total = 162;
if(total is greater than 100) {
// take 20% off the total
} else {
// take 5% off the total
}If you spend $200 or more, then you get 30% off.
If you spend $100 or more, then you get 20% off.
Otherwise, you get 5% off.
var total = 162;
if(total is greater than 200) {
// take 30% off the total
} else if(total is greater than 100) {
// take 20% off the total
}
else {
// take 5% off the total
}// Write a function whoIsTaller takes 2 parameters
// and always returns ‘a’ is taller than ‘b’.
// However if ‘Beyonce” is a parameter,
// she will always be taller.
whoIsTaller('Jill', 'Jack');
// Output:
// Jill is taller than Jack!
whoIsTaller('Jack', 'Beyonce');
// Output:
// Beyonce is taller than Jack!1
2
Open unzipped folder in Atom
3
4
Create file in same folder named main.js