diff --git a/Week1/homework/README.MD b/Week1/homework/README.MD new file mode 100644 index 000000000..f08e451bb Binary files /dev/null and b/Week1/homework/README.MD differ diff --git a/Week1/homework/js-exercises/01logHello.js b/Week1/homework/js-exercises/01logHello.js new file mode 100644 index 000000000..3504695e7 --- /dev/null +++ b/Week1/homework/js-exercises/01logHello.js @@ -0,0 +1,11 @@ +'use strict' +console.log("Halo, dunia!"); // Indonesian +console.log("Ciao, mondo!"); // Italian +console.log("Hola, mundo!"); // Spanish +console.log("你好, 世界!"); // Chinese +console.log("こんにちは, 世界!"); // Japanese +console.log("Здравствуй, мир!"); // Russian +console.log("여보세요, 세계!"); // Korean +console.log("Olá, mundo!"); // "Portuguese" +console.log("γειά σου, κόσμος!"); // "Greek" +console.log("Bonjour, monde!"); // French diff --git a/Week1/homework/js-exercises/02debug.js b/Week1/homework/js-exercises/02debug.js new file mode 100644 index 000000000..31acf69f1 --- /dev/null +++ b/Week1/homework/js-exercises/02debug.js @@ -0,0 +1,2 @@ +'use strict' +console.log('I\'m awesome'); diff --git a/Week1/homework/js-exercises/03logNumber.js b/Week1/homework/js-exercises/03logNumber.js new file mode 100644 index 000000000..9920e5ed9 --- /dev/null +++ b/Week1/homework/js-exercises/03logNumber.js @@ -0,0 +1,13 @@ +'use strict' +// 1. First, declare your variable `numberX`. Do not _initialize_ it (which means, don't give it a value) yet. +let numberX; +// 2. Add a `console.log` statement that explains in words _what you think_ the value of `x` is, like in this example. +console.log("I think it is 'undefined'"); +// 3. Add a `console.log` statement that logs the value of `numberX`. +console.log(numberX); +// 4. Now _initialize_ your variable `numberX` with a number (also called an `integer` in computer science terms). +numberX = 10; +// 5. Next, add a `console.log` statement that explains _what you think_ the value of `numberX` is. +console.log("I think it is number '10'"); +// 6. Add a `console.log` statement that logs the value of `numberX`. +console.log(numberX); diff --git a/Week1/homework/js-exercises/04logString.js b/Week1/homework/js-exercises/04logString.js new file mode 100644 index 000000000..082e6194c --- /dev/null +++ b/Week1/homework/js-exercises/04logString.js @@ -0,0 +1,13 @@ +'use strict' +// 1. Declare a variable `myString` and assign a string to it. Use your full name, including spaces, as the content for the string. +let myString = "Mustafa TUNCER"; +// 2. Write a `console.log` statement in which you explain in words _what you think_ the value of the string is. +console.log("It should print \"Mustafa TUNCER\""); +// 3. Now `console.log` the variable `myString`. +console.log(myString); +// 4. Now reassign to the variable `myString` a new string. +myString = myString.split(' ')[0]; +// 5. Just like what you did before write a `console.log` statement that explains in words _what you think_ will be logged to the console. +console.log("It should print \"Mustafa\""); +// 6. Now console.log `myString` again. +console.log(myString); diff --git a/Week1/homework/js-exercises/05roundANumber.js b/Week1/homework/js-exercises/05roundANumber.js new file mode 100644 index 000000000..e64e89ddd --- /dev/null +++ b/Week1/homework/js-exercises/05roundANumber.js @@ -0,0 +1,13 @@ +'use strict' +// 1. Declare a variable `z` and assign the number 7.25 to it. +let z = 7.25; +// 2. Write a `console.log` statement in which you log the value of `z`. +console.log(z); +// 3. Declare another variable `a` that has the value of `z` but rounded to the nearest integer. +let a = Math.round(z); +// 4. Write a `console.log` statement in which you log the value of `a`. +console.log(a); +// 5. So now we have `z` and `a` find a way to compare the two values and store the highest of the two in a new variable. +let j = a > z ? a : z; +// 6. Write a `console.log` statement in which you log the value of the highest value. +console.log(j); diff --git a/Week1/homework/js-exercises/06logArray.js b/Week1/homework/js-exercises/06logArray.js new file mode 100644 index 000000000..422510114 --- /dev/null +++ b/Week1/homework/js-exercises/06logArray.js @@ -0,0 +1,15 @@ +'use strict' +// 1. Declare variable and assign to it an empty array. Make sure that the name of the variable indicates it contains more than 1 item. For example `items` instead of `item`. +const items = []; +// 2. Write a `console.log` statement that explains in words _what you think_ the value of the array is. +console.log("The value of the array should be an empty array. '[]'"); +// 3. Write a `console.log` statement that logs the array. +console.log(items); +// 4. Create a new variable with an array that has 3 of your favorite animals, each in a different string. Make sure the name of the variables says something about what the variable contains. +const pets = ['Horse', "Pikachu", `Parrot`]; +// 5. Write a `console.log` statement that logs the second array. +console.log(pets); +// 6. Add a statement that adds another string ("Piglet)" to the array of animals. +pets.push("Piglet"); +// 7. Write a `console.log` statement that logs the second array! +console.log(pets); diff --git a/Week1/homework/js-exercises/07logStringLength.js b/Week1/homework/js-exercises/07logStringLength.js new file mode 100644 index 000000000..e8092b276 --- /dev/null +++ b/Week1/homework/js-exercises/07logStringLength.js @@ -0,0 +1,7 @@ +'use strict' +// 1. Declare a variable called `mySentence` and initialize it with the following string: "Programming is so interesting!". +let mySentence = "Programming is so interesting!"; +// 2. Figure out (using Google) how to get the length of `mySentence`. +let lengthOfTheString = mySentence.length; +// 3. Write a `console.log` statement to log the length of `mySentence`. +console.log(lengthOfTheString); diff --git a/Week1/homework/js-exercises/08typeCheck.js b/Week1/homework/js-exercises/08typeCheck.js new file mode 100644 index 000000000..f7d42707d --- /dev/null +++ b/Week1/homework/js-exercises/08typeCheck.js @@ -0,0 +1,24 @@ +'use strict' +// 1. Declare 4 variables: 2 must be `strings` and 2 must be `objects` +let s1 = "a"; +let s2 = "b"; +let o1 = null; +let o2 = {}; +// 2. Create 8 conditional statements, where for each you check if the data type of one variable is the same as the other +console.log(typeof s1 === typeof s2); +console.log(typeof s1 === typeof o1); +console.log(typeof s1 === typeof o2); +console.log(typeof s2 === typeof o1); +console.log(typeof s2 === typeof o2); +console.log(typeof o1 === typeof o2); +console.log(typeof s1 === typeof s1); +console.log(typeof s2 === typeof s2); +// 3. Find out how to check the type of a variable +console.log("To find the type of a variable, we use 'typeof'"); +// 4. Write 2 `console.log` statements to log the type of 2 variables, each with a different data type +console.log(typeof s1); +console.log(typeof o1); +// 5. Now compare the types of your different variables with one another +console.log(typeof s1 === typeof s2); +// 6. Log `Not the same...` when the types are different +console.log(typeof s1 === typeof o1 ? "The same" : "Not the same..."); diff --git a/Week1/homework/js-exercises/09logRemainder.js b/Week1/homework/js-exercises/09logRemainder.js new file mode 100644 index 000000000..864bcd072 --- /dev/null +++ b/Week1/homework/js-exercises/09logRemainder.js @@ -0,0 +1,15 @@ +'use strict' +// 1. If `x` equals 7, and the only other statement is `x = x % 3`, what would be the value of `x` after the calculation? +let x = 7; +x = x % 3; +console.log("Expecting 1, Remainder is: ", x); +// 2. If `y` equals 21, and the only other statement is `x = x % 4`, what would be the value of `y` after the calculation? +let y = 21; +x = x % 4; +console.log("Since the operation is for the X, y should be 21, and it is: ", y); +console.log("Lets say it was for y. for y = 21; y % 4 should be 1. It is: ", y % 4); +// 3. If `z` equals 13, and the only other statement is `x = x % 2`, what would be the value of `z` after the calculation? +let z = 13; +x = x % 2; +console.log("Since the operation is for the X, z should be 13, and it is: ", z); +console.log("Lets say it was for z. for z = 13; z % 2 should be 1. It is: ", z % 2); diff --git a/Week1/homework/js-exercises/10compareArrays.js b/Week1/homework/js-exercises/10compareArrays.js new file mode 100644 index 000000000..7cae040a4 --- /dev/null +++ b/Week1/homework/js-exercises/10compareArrays.js @@ -0,0 +1,9 @@ +'use strict' +// 1. Declare 2 variables, that each hold an array. The first array should have 4 items, the second 7 items +const tools = ['hammer', 'axe', 'screwdriver', 'wrench']; +const animals = ['rabbit', 'hare', 'hamster', 'cow', 'sheep', 'goat', 'donkey']; +// 2. Find out how to get the length of each array. Write a `console.log` statement that shows the length of each array +console.log("The length of tools array is: ", tools.length); +console.log("The length of animals array is: ", animals.length); +// 3. Write a conditional statement that checks if both are of equal length. If they are, log to the console `They are the same!`, if not log `Two different sizes` +console.log(tools.length === animals.length ? "They are the same!" : "Two different sizes");