Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 105 additions & 21 deletions 01-Fundamentals-Part-1/starter/assignments.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// JavaScript Fundamentals 1


// Values and Variables

// // Values and Variables
// let country = "United States of America";
// let continent = "North America";
// let population = 340.1;
Expand All @@ -12,8 +10,8 @@
// console.log(population);


// Data Types

// // Data Types
// let isIsland = false;
// let language;

Expand All @@ -23,29 +21,115 @@
// console.log(typeof language);


// let, const, and var

const country = "United States of America";
const continent = "North America";
let population = 340.1;
const isIsland = false;
const language = "English";
// // let, const, and var
// const country = "United States of America";
// const continent = "North America";
// let population = 340.1;
// const isIsland = false;
// const language = "English";
// isIsland = true;


// Basic Operators

const halfPopulation = population / 2;
console.log(halfPopulation);
// // Basic Operators
// const halfPopulation = population / 2;
// console.log(halfPopulation);

// population += 1;
// console.log(population);

// const populationFinland = 6;
// console.log(population > populationFinland);

// const averagePopulation = 33;
// console.log(population < averagePopulation);

// const description = country + " is in " + continent + ", and its " + population + " million people speak " + language
// console.log(description);



// // Strings and Template Literals
// const newDescription = `${country} is in ${continent}, and its ${population} million people speak ${language}`
// console.log(newDescription);


population += 1;
console.log(population);

const populationFinland = 6;
console.log(population > populationFinland);
// // Taking Decisions: if/else Statements
// if (population > averagePopulation) {
// console.log(`${country}'s population is ${population - averagePopulation} above average.`);
// } else {
// console.log(`${country}'s population is ${averagePopulation - population} below average.`);
// }

const averagePopulation = 33;
console.log(population < averagePopulation);

const description = country + " is in " + continent + ", and its " + population + " million people speak " + language
console.log(description);

// // Type Conversion and Coercion
// console.log("9" - "5"); // 4
// console.log("19" - "13" + "17"); // "617"
// console.log("19" - "13" + 17); // 23
// console.log("123" < 57); // false
// console.log(5 + 6 + "4" + 9 - 4 - 2); // 1143



// // Equality Operators: == vs ===
// const numNeighbors = Number(prompt("How many neighboring countries does your country have?"));

// if (numNeighbors === 1) {
// console.log("Only 1 border!");
// } else if (numNeighbors > 1) {
// console.log("More than 1 border");
// } else {
// console.log("No borders");
// }



// // Logical Operators
// const country = "United States of America";
// const continent = "North America";
// let population = 340.1;
// const isIsland = false;
// const language = "English";

// if (language === "English" && population < 50 && !isIsland) {
// console.log(`Sarah can live in ${country}!`);
// } else {
// console.log(`${country} does not meet Sarah's criteria`);
// }



// // The Switch Statement
// const language = "english"
// switch (language) {
// case "chinese":
// case "mandarin":
// console.log("MOST number of native speakers");
// break
// case "spanish":
// console.log("2nd place in number of native speakers");
// break
// case "english":
// console.log("3rd place");
// break
// case "hindi":
// console.log("Number 4");
// break
// case "arabic":
// console.log("5th most spoken language");
// break
// default:
// console.log("Great language too");
// }



// // The Conditional (Ternary) Operator
// const country = "United States of America";
// const averagePopulation = 33;
// let population = 340.1;

// console.log(`${country}'s population is ${population > averagePopulation ? "above" : "below"} average`);
73 changes: 64 additions & 9 deletions 01-Fundamentals-Part-1/starter/codingChallenges.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,70 @@
// JavaScript Fundamentals Part 1

// Coding Challenge #1
const weightMark = 78;
const heightMark = 1.69;
// // Coding Challenge #1
// const weightMark = 78;
// const heightMark = 1.69;

const weightJohn = 92;
const heightJohn = 1.95;
// const weightJohn = 92;
// const heightJohn = 1.95;

const bmiMark = weightMark / heightMark ** 2;
const bmiJohn = weightJohn / (heightJohn * heightJohn);
// // const weightMark = 95;
// // const heightMark = 1.88;

const markHigherBMI = bmiMark > bmiJohn;
// // const weightJohn = 85;
// // const heightJohn = 1.76;

console.log(bmiMark, bmiJohn, markHigherBMI);
// const bmiMark = weightMark / heightMark ** 2;
// const bmiJohn = weightJohn / (heightJohn * heightJohn);

// const markHigherBMI = bmiMark > bmiJohn;

// console.log(bmiMark, bmiJohn, markHigherBMI);



// // Coding Challenge #2
// if (bmiMark > bmiJohn) {
// console.log(`Mark's BMI (${bmiMark}) is higher than John's (${bmiJohn})!`);
// } else {
// console.log(`John's BMI (${bmiJohn}) is higher than Mark's (${bmiMark})!`);
// }



// // Coding Challenge #3
// // const scoreDolphins = (96 + 108 + 89) / 3;
// // const scoreKoalas = (88 + 91 + 110) / 3;
// // console.log(scoreDolphins, scoreKoalas);

// // if (scoreDolphins > scoreKoalas) {
// // console.log("Dolphins win!");
// // } else if (scoreKoalas > scoreDolphins) {
// // console.log("Koalas win!");
// // } else {
// // console.log("Draw!");
// // }

// // const scoreDolphins = (97 + 112 + 101) / 3;
// // const scoreKoalas = (109 + 95 + 123) / 3;

// const scoreDolphins = (97 + 112 + 101) / 3;
// const scoreKoalas = (109 + 95 + 106) / 3;
// console.log(scoreDolphins, scoreKoalas);

// if (scoreDolphins > scoreKoalas && scoreDolphins >= 100) {
// console.log("Dolphins win!");
// } else if (scoreKoalas > scoreDolphins && scoreKoalas >= 100) {
// console.log("Koalas win!");
// } else if (scoreDolphins === scoreKoalas && scoreDolphins >= 100) {
// console.log("Draw!");
// } else {
// console.log("No winner");
// }



// // Coding Challenge #4
// const bill = 275;
// const tip = (bill >= 50 && bill <= 300) ? bill * .15 : bill * .20;

// console.log(`The bill was ${bill}, the tip was ${tip}, and the total value was ${bill + tip}`);
Loading