Skip to content

Commit

Permalink
reorganizing
Browse files Browse the repository at this point in the history
  • Loading branch information
BrightBoost committed Dec 2, 2021
2 parents 711a22a + a870f9e commit 67a8d8a
Show file tree
Hide file tree
Showing 125 changed files with 4,052 additions and 1 deletion.
Binary file added .DS_Store
Binary file not shown.
Binary file added Chapter 01/.DS_Store
Binary file not shown.

This file was deleted.

2 changes: 2 additions & 0 deletions Chapter 01/Code Samples/ch1_alert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//alert("Saying hi from a different file!");
prompt("Hi! How are you?");
5 changes: 5 additions & 0 deletions Chapter 01/Code Samples/ch1_popup1_hithere.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<script type="text/javascript">
alert("Hi there!");
</script>
</html>
3 changes: 3 additions & 0 deletions Chapter 01/Code Samples/ch1_popup2_prompt.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<html>
<script type="text/javascript" src="ch1_alert.js"></script>
</html>
13 changes: 13 additions & 0 deletions Chapter 01/Code Samples/ch1_welcome_new_scared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
let status = "new";
let scared = true;
if (status === "new") {
console.log("Welcome to JavaScript!");
if (scared) {
console.log("Don't worry you will be fine!");
} else {
console.log("You're brave! You are going to do great!");
}
} else {
console.log("Welcome back, I new you'd like it!");
}

11 changes: 11 additions & 0 deletions Chapter 02/Code Samples/ch2_boolean_and_comparison.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let bool1 = false;
let bool2 = true;
console.log(typeof bool1)

let str1 = "JavaScript is fun!";
let str2 = "JavaScript is fun!";
console.log("These two strings are the same:", str1 === str2);

let sym1 = Symbol("JavaScript is fun!");
let sym2 = Symbol("JavaScript is fun!");
console.log("These two Symbols are the same:", sym1 === sym2);
43 changes: 43 additions & 0 deletions Chapter 02/Code Samples/ch2_calculations_conversions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// let nr1 = 2;
// let nr2 = "2";
// console.log(nr1 * nr2);

// let nr1 = 2;
// let nr2 = "2";
// console.log(nr1 + nr2);

// let nrToStr = 6;
// nrToStr = String(nrToStr);
// console.log(nrToStr, typeof nrToStr);

// let strToNr = "12";
// strToNr = Number(strToNr);
// console.log(strToNr, typeof strToNr);

// let strToBool = "any string will return true";
// strToBool = Boolean(strToBool);
// console.log(strToBool, typeof strToBool);

// let nullToNr = null;
// nullToNr = Number(nullToNr);
// console.log("null", nullToNr, typeof nullToNr);

// let strToNr = "";
// strToNr = Number(strToNr);
// console.log("empty string", strToNr, typeof strToNr);

// let strToNr2 = "hello";
// strToNr2 = Number(strToNr2);
// console.log(strToNr2, typeof strToNr2);

// let strToBool = "";
// strToBool = Boolean(strToBool);
// console.log(strToBool, typeof strToBool);

// let strToBool2 = "false";
// strToBool2 = Boolean(strToBool2);
// console.log(strToBool2, typeof strToBool2);

// let nr1 = 2;
// let nr2 = "2";
// console.log(nr1 + Number(nr2));
25 changes: 25 additions & 0 deletions Chapter 02/Code Samples/ch2_strings_and_types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
let str = "Hello, what's your name? Is it \"Mike\"?";
console.log(str);
let str2 = 'Hello, what\'s your name? Is it "Mike"?';
console.log(str2);

let str3 = "New \nline."
let str4 = "I'm containing a backslash: \\!";
console.log(str3);
console.log(str4);

let str = "Hello";
let nr = 7;
let bigNr = 12345678901234n;
let bool = true;
let sym = Symbol("unique");
let undef = undefined;
let unknown = null;

console.log("str", typeof str);
console.log("nr", typeof nr);
console.log("bigNr", typeof bigNr);
console.log("bool", typeof bool);
console.log("sym", typeof sym);
console.log("undef", typeof undef);
console.log("unknown", typeof unknown);
64 changes: 64 additions & 0 deletions Chapter 02/Code Samples/ch2_types_and_operations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// let nr1 = 12;
// let nr2 = 14;
// let str1 = "Hello ";
// let str2 = "addition";
// let result1 = nr1 + nr2;
// let result2 = str1 + str2;
// console.log(result1, result2);

// let nr1 = 20;
// let nr2 = 4;
// let str1 = "Hi ";
// let nr3 = 3;
// let result1 = nr1 - nr2;
// let result2 = str1 - nr3;
// console.log(result1, result2);

// let nr1 = 15;
// let nr2 = 10;
// let str1 = "Hi";
// let nr3 = 3;
// let result1 = nr1 * nr2;
// let result2 = str1 * nr3;
// console.log(result1, result2);

// let nr1 = 30;
// let nr2 = 5;
// let result1 = nr1 / nr2;
// console.log(result1);

// let nr1 = 2;
// let nr2 = 3;
// let result1 = nr1 ** nr2;
// console.log(result1);

// let nr1 = 10;
// let nr2 = 3;
// let result1 = nr1 % nr2;
// console.log(`${nr1} % ${nr2} = ${result1}`);

// let nr3 = 8;
// let nr4 = 2;
// let result2 = nr3 % nr4;
// console.log(`${nr3} % ${nr4} = ${result2}`);

// let nr5 = 15;
// let nr6 = 4;
// let result3 = nr5 % nr6;
// console.log(`${nr5} % ${nr6} = ${result3}`);

// let nr = 4;
// nr++;
// console.log(nr);

// let nr = 2;
// console.log(nr++);
// console.log(nr);

// let nr = 2;
// console.log(++nr);

let nr1 = 4;
let nr2 = 5;
let nr3 = 2;
console.log(nr1++ + ++nr2 * nr3++);
11 changes: 11 additions & 0 deletions Chapter 02/Code Samples/ch2_undefined_null.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
let unassigned;
console.log(unassigned);

let terribleThingToDo = undefined;
let lastname;
console.log("Same undefined:", lastname === terribleThingToDo);

let betterOption = null;
console.log("Same null:", lastname === betterOption);

let empty = null;
10 changes: 10 additions & 0 deletions Chapter 02/Code Samples/ch2_variables_basics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let firstname = "Maria";
firstname = "Jacky";

let nr1 = 12;
var nr2 = 8;
const pi = 3.14159;

// throws a TypeError
const someConstant = 3;
someConstant = 4;
7 changes: 7 additions & 0 deletions Chapter 02/Code Samples/ch2_variables_number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let intNr = 1;
let decNr = 1.5;
let expNr = 1.4e15;

let bigNr = 90071992547409920n;
// typeError
let result = bigNr + intNr;
6 changes: 6 additions & 0 deletions Chapter 02/Code Samples/ch2_variables_string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let singleString = 'Hi there!';
let doubleString = "How are you?";

let language = "JavaScript";
let message = `Let's learn ${language}`;
console.log(message);
100 changes: 100 additions & 0 deletions Chapter 03/Code Samples/ch3_arrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
arr1 = new Array("purple", "green", "yellow");
arr2 = ["black", "orange", "pink"];

arr3 = new Array(10);
arr4 = [10];

console.log(arr3);
console.log(arr4);

cars = ["Toyota", "Renault", "Volkswagen"];
console.log(cars[0]);
console.log(cars[1]);
console.log(cars[2]);
console.log(cars[3]);
console.log(cars[-1]);

cars[0] = "Tesla";
console.log(cars[0]);

cars[3] = "Kia";
cars[-1] = "Fiat";
console.log(cars[3]);
console.log(cars[-1]);

colors = ["black", "orange", "pink"]
booleans = [true, false, false, true];
emptyArray = [];

console.log("Length of colors:", colors.length);
console.log("Length of booleans:", booleans.length);
console.log("Length of emtpy array:", emptyArray.length);

lastElement = colors[colors.length - 1];
console.log(lastElement);

numbers = [12, 24, 36];
numbers[-1] = 0;
numbers[5] = 48;
console.log(numbers.length);

console.log("numbers", numbers);

favoriteFruits = ["grapefruit", "orange", "lemon"];
favoriteFruits.push("tangerine");

let lengthOfFavoriteFruits = favoriteFruits.push("lime");
console.log(lengthOfFavoriteFruits);
console.log(favoriteFruits);

let arrOfShapes = ["circle", "triangle", "rectangle", "pentagon"];
arrOfShapes.splice(2, 0, "square", "trapezoid");
console.log(arrOfShapes);

let arr5 = [1, 2, 3];
let arr6 = [4, 5, 6];
let arr7 = arr5.concat(arr6);
console.log(arr7);

let arr8 = arr7.concat(7, 8, 9);
console.log(arr8);

arr8.pop();
console.log(arr8);

arr8.shift();
console.log(arr8);

arr8.splice(1, 3);
console.log(arr8);

delete arr8[0];
console.log(arr8);

let findValue = arr8.find(() => e === 6);
let findValue2 = arr8.find(() => e === 8);
console.log(findValue, findValue2);

let findIndex = arr8.indexOf(6);
let findIndex2 = arr8.indexOf(10);
let findIndex3 = arr8.indexOf(6, 2);
console.log(findIndex, findIndex2, findIndex3);

let animals = ["dog", "horse", "cat", "platypus", "dog"]
let lastDog = animals.lastIndexOf("dog");
console.log(lastDog);


let names = ["James", "Alicia", "Fatiha", "Maria", "Bert"];
names.sort();

let ages = [18, 72, 33, 56, 40];
ages.sort();

console.log(names);
console.log(ages);

names.reverse();
console.log(names);

console.log(typeof arr1);
Loading

0 comments on commit 67a8d8a

Please sign in to comment.