Amy Norris
Director
Alex Herron
Co-Director
Julie Batson
Curriculum Director
Gabi Dombrowski
Mentor Director
Kim Watt
Marketing Director
Vanessa Shultz
Presentation Director
Anita Golden-Burrell
Technical Materials Director
Behind the wooden wall in the kitchen
Don’t be discouraged if you don’t finish each worksheet section before the next presentation section begins.
We cover a lot of difficult material that will take time to understand. We are here (and on Slack after the session) to help!
JS aka JavaScript
JScript
ECMAScript
<script type="text/javascript">
const myJSVariable = "hey ladies!"
</script>
<script src="assets/js/my-javascript-file.js"></script>
let myName = "John";
myName = "Jane"; // "Jane"
const myName = "John";
myName = "Jane"; // TypeError: Assignment to constant variable.
const myVariable = 5;
myVariable;
const double = "Hello World!";
const single = 'Hello World!';
typeof(double); // string
const hello = "Hello";
const world = "World!";
const helloWorld = hello + " " + world;
// "Hello World!"
const isTrue = true;
const isFalse = false;
typeof(isTrue); // boolean
const num = 5;
const decimal = 5.5;
typeof(num); // number
const num = "5";
typeof(num); // string
let x;
typeof(x); // undefined
let x = null;
typeof(x); // object
Presentation: https://bit.ly/cc-js-slides
Worksheet: https://bit.ly/cc-worksheet
const myAge = 21 + 10; // 31
const agePeopleThinkIAm = 31 - 6; // 25
const myDogsAge = 38 * 38; // 1444
const ozWineBottleSplitFourWays = 25.4 / 4; // 6.35
const cookiesLeftAfterThreeKidsSplitCookiesEquallyYeahRight = 16 % 3; // 1
let myAge = 21;
myAge++; // 22
let cookies = 5;
cookies--; // 4
const thirtyFive = 10 + 25; // 35
const textString = 'happy' + 'birthday'; // happybirthday
const textAndNumberString = 'happy' + 35 + 'birthday'; // happy35birthday
const numberAndTextString = 'happy' + ' ' + 35 + ' ' + 'birthday'; // happy 35 birthday
const gotcha = '10' + 25;
// 1025
const myAge = 21;
myAge == 21; // true
const cookies = 0;
const drinks = '0';
cookies === drinks; // false
const cookies = 0;
const drinks = '0';
cookies !== drinks; // true
const myAge = 21;
myAge != 21; // false
const myAge = 18;
myAge > 21; // false
const myAge = 18;
myAge < 21; // true
const myAge = 18;
myAge > 21 ? 'You are older than me' : 'You are younger than me'; // You are younger than me
Presentation: https://bit.ly/cc-js-slides
Worksheet: https://bit.ly/cc-worksheet
function sayHello() {
console.log('Hello!');
}
sayHello(); // Hello!
const functionName = function(optional, parameters, here) {
// function logic here
};
functionName();
functionName('hello');
//with 1 parameter
const orderDrink = function(drinkName) {
return 'I would like a ' + drinkName + ' please.';
};
orderDrink('gin and tonic');
//'I would like a gin and tonic please.';
function functionName() {
//function logic here
}
//without parameters
function orderMyFavoriteDrink() {
return 'I want a margarita.';
}
orderMyFavoriteDrink();
//'I want a margarita.'
const sayHello = (name) => {
console.log('Hello ' + name + '!');
}
sayHello('KC Wit'); // Hello KC Wit!
let drink; // declares variable but doesn't set
function setDrink (cocktail) {
drink = cocktail;
}
setDrink('martini');
//undefined is returned but drink variable is now set to 'martini'
alert('My current drink of choice is a ' + drink);
//alert will display 'My current drink of choice is a martini'
if (condition) {
// code to execute if condition is true
} else {
// code to execute if condition is false
}
const age = 21;
if (age >= 21) {
console.log('You can drink!');
} else {
console.log('You can't drink!');
}
// You can drink!
const usersName = 'Heidi';
if (usersName.length > 0) {
submitDrinkOrder();
} else {
alert('Please enter your name before submitting your drink order.');
}
// Submits a drink order
const usersName = 'Heidi';
const usersAge = 21;
if (usersName.length > 0) {
if (usersAge >= 21) {
submitDrinkOrder();
} else {
alert('You must be 21 to submit a drink order.');
}
} else {
alert('Please enter your name.');
}
if (condition) {
// code to execute if condition is true
}
if (condition) {
// code to execute if condition is true
} else if (condition) {
// code to execute if first condition false, but second true
} else {
// code to execute if condition is false
}
const name = 'Heidi';
console.log(name);
// Heidi
const getSquareFeet = (height, width) => {
return height * width;
}
console.log(getSquareFeet(10, 15));
// 5
console.log('name', name);
console.log('square feet', getSquareFeet(13, 20);
Presentation: https://bit.ly/cc-js-slides
Worksheet: https://bit.ly/cc-worksheet
const cocktails = ['Code on the Beach', 'jQuery Sour'];
const drinksIveConsumed = [0, 1, 2, 3, 4, 5, 6, 7, 'none of the above'];
const cocktails = new Array();
const drinksIveConsumed = [];
const cocktails = ['Code on the Beach', 'jQuery Sour', 'Silicon Valley', 'JS on Rocks'];
console.log(cocktails[0]);
// Code on the Beach
console.log(cocktails[1]);
// jQuery Sour
console.log(cocktails[cocktails.length - 1]);
// JS on Rocks
for (initialization; condition; increment) {
// code to execute while condition is true
}
const cocktails = ['Code on the Beach', 'jQuery Sour'];
for (let i = 0; i < cocktails.length; i++) {
console.log(cocktails[i], i);
}
// Code on the Beach 0
// jQuery Sour 1
cocktails.forEach(function(cocktail, index) {
console.log(cocktail, index);
});
// Code on the Beach 0
// jQuery Sour 1
Use the push() method
(some array).push(...some item)
const cocktails = ['Code on the Beach', 'jQuery Sour'];
cocktails.push('Silicon Valley');
console.log(cocktails);
// ['Code on the Beach', 'jQuery Sour', 'Silicon Valley']
Use the pop() method
(some array).pop()
const cocktails = ['Code on the Beach', 'jQuery Sour', 'Silicon Valley'];
cocktails.pop();
console.log(cocktails);
// ['Code on the Beach', 'jQuery Sour']
Use the unshift() method
(some array).unshift(...some item)
const cocktails = ['Code on the Beach', 'jQuery Sour'];
cocktails.unshift('Silicon Valley');
console.log(cocktails);
// ['Silicon Valley', 'Code on the Beach', 'jQuery Sour']
Use the shift() method
(some array).shift()
const cocktails = ['Code on the Beach', 'jQuery Sour', 'Silicon Valley'];
cocktails.shift();
console.log(cocktails);
// ['jQuery Sour', 'Silicon Valley']
Presentation: https://bit.ly/cc-js-slides
Worksheet: https://bit.ly/cc-worksheet
HTML
<button
id="cocktail-section"
onclick="clickHandler('Hi there LadyDev!')"
></button>
JS
const clickHandler = function (text) {
alert(text);
};
#LadyDevs #KCWiT
#CodingAndCocktailsKC