- Course outline: https://gist.github.com/ianmstew/3fdf6c1c232aa88c37f121784d537695
- JavaScript documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript
- Common references
- Variable declarations: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Declarations
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#Logical
let isRaining = true;
let isDaytime = true;
let shouldIGoForAWalk = !isRaining && isDaytime;
console.log('Should I go for a walk?', shouldIGoForAWalk);
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators#String
let firstName = 'Zoe';
let lastName = 'Proom';
let fullName = firstName + ' ' + lastName;
console.log('Full name:', fullName);
let a = 1.5;
let b = 2;
let product = a * b;
console.log('Product:', product);
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null
// undefined
let someVariable;
console.log('someVariable:', someVariable);
someVariable = null;
console.log('someVariable:', someVariable);
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals
let isRaining = true;
let isDaytime = true;
let shouldIGoForAWalk = !isRaining && isDaytime;
console.log('shouldIGoForWalk:', shouldIGoForAWalk);
if (shouldIGoForAWalk) {
console.log("Let's go!");
} else {
console.log("I'd better not.");
}
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals
// INPUTS
let fullName = 'Zoe Proom';
let userRole = 'read'; // read, write, admin
// APPLICATION
console.log(fullName +' is attempting to administer...');
// === here is converting the _contents_ of `userRole` and the string literal 'admin' to a boolean
if (userRole === 'admin') {
console.log('Success!')
} else {
console.log('Access denied.')
}
Falsy: https://developer.mozilla.org/en-US/docs/Glossary/Falsy
if ('' || 0 || null || undefined || false) {
console.log('falsy');
} else {
console.log('truthy');
}
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/conditionals
// INPUTS
let userName = 'Jane';
let userAge = 17;
// APPLICATION
// TODO: Print (with console.log) "Jane is a minor" if userAge is less than 18, otherwise print "Jane is an adult"