diff --git a/Week2/Homework-Week2/1-greetings_in_different_languages.js b/Week2/Homework-Week2/1-greetings_in_different_languages.js new file mode 100644 index 000000000..90e17ce19 --- /dev/null +++ b/Week2/Homework-Week2/1-greetings_in_different_languages.js @@ -0,0 +1,4 @@ +console.log ("Hello World!"); //English +console.log ("Merhaba Dunya!"); //Turkish +console.log ("Hallo Wereld!"); //Dutch +console.log ("Hola Munda!"); //Spanish \ No newline at end of file diff --git a/Week2/Homework-Week2/10-more_about_arrays.js b/Week2/Homework-Week2/10-more_about_arrays.js new file mode 100644 index 000000000..78e9c6d2b --- /dev/null +++ b/Week2/Homework-Week2/10-more_about_arrays.js @@ -0,0 +1,22 @@ +console.log("We can store multiple types in an array"); +let memberInfo = ["Mike", "Amsterdam", 33, true]; +console.log("I store multiple data type in memberInfo array. The array is: " + memberInfo); +console.log("I think we can compare 6/0 and 10/0"); +console.log("Let's make firstInfinity = 6/0 and secondInfinity = 10/0"); +let firstInfinity = 6/0; +let secondInfinity = 10/0; +let comparingTwoInfinities; +console.log("let firstInfinity = 6/0 --> " + firstInfinity); +console.log("let secondInfinity = 10/0 --> " + secondInfinity); +if (firstInfinity === secondInfinity) { + comparingTwoInfinities = "6/0 and 10/0 are both infinity, equal and can be comperable"; +} else { + comparingTwoInfinities = "We can not compare firstInfinity and secondInfinity"; +} +console.log("After comparing 6/0 and 10/0 the result is: " + comparingTwoInfinities); +console.log("\n"); +console.log("In this homework I learn:\n1-To use escape character." + +"\n2-To use console.log()\n3-The value of variables\n4-The type of variables\n" + +"5-Comparing variables with value and type\n6-To use different data types in JS\n" + +"7-To use typeof operator\n8-To use length property\n9-To ose % operator\n" + +"To compare infinity"); \ No newline at end of file diff --git a/Week2/Homework-Week2/2-using_quotes_and_escape_chars.js b/Week2/Homework-Week2/2-using_quotes_and_escape_chars.js new file mode 100644 index 000000000..605692400 --- /dev/null +++ b/Week2/Homework-Week2/2-using_quotes_and_escape_chars.js @@ -0,0 +1,3 @@ +console.log("I'm awesome"); //Solution 1 - Using double quotes +console.log('I\'m awesome'); // Solution 2 - Using escape character +console.log("\n"); \ No newline at end of file diff --git a/Week2/Homework-Week2/3-declaring_initializing_and_changing_variables_numbers.js b/Week2/Homework-Week2/3-declaring_initializing_and_changing_variables_numbers.js new file mode 100644 index 000000000..cf04856fd --- /dev/null +++ b/Week2/Homework-Week2/3-declaring_initializing_and_changing_variables_numbers.js @@ -0,0 +1,7 @@ +var x; +console.log("I think the value of my variable 'x' will be: undefined"); +console.log(x); +x = 8; +console.log("I think the value of my variable 'x' will be: 8"); +console.log(x); +console.log("\n"); \ No newline at end of file diff --git a/Week2/Homework-Week2/4-declaring_initializing_and_changing_variables_string.js b/Week2/Homework-Week2/4-declaring_initializing_and_changing_variables_string.js new file mode 100644 index 000000000..5a8260409 --- /dev/null +++ b/Week2/Homework-Week2/4-declaring_initializing_and_changing_variables_string.js @@ -0,0 +1,7 @@ +var y = "Hello"; +console.log("I think the value of my string variable 'y' will be: Hello"); +console.log(y); +y = "Hello World"; +console.log("I think the value of my string variable 'y' will be: Hello World"); +console.log(y); +console.log("\n"); \ No newline at end of file diff --git a/Week2/Homework-Week2/5-rounding_numbers_to_nearest_integer.js b/Week2/Homework-Week2/5-rounding_numbers_to_nearest_integer.js new file mode 100644 index 000000000..e9f482d5c --- /dev/null +++ b/Week2/Homework-Week2/5-rounding_numbers_to_nearest_integer.js @@ -0,0 +1,7 @@ +var z = 7.25; +console.log(z); +var a = Math.round(z); +console.log(a); +var b = Math.max(z, a); +console.log(b); +console.log("\n"); \ No newline at end of file diff --git a/Week2/Homework-Week2/6-working_with_arrays.js b/Week2/Homework-Week2/6-working_with_arrays.js new file mode 100644 index 000000000..312a5277a --- /dev/null +++ b/Week2/Homework-Week2/6-working_with_arrays.js @@ -0,0 +1,8 @@ +var myFavoriteAnimals = []; +console.log("I think the value of my array variable 'myFavoriteAnimals' will be: an empty array []"); +console.log(myFavoriteAnimals); +myFavoriteAnimals = ["Cats", "Pandas", "Rabbits", "Ducks"]; +console.log(myFavoriteAnimals); +myFavoriteAnimals [4] = "Baby Pig"; +console.log(myFavoriteAnimals); +console.log("\n"); \ No newline at end of file diff --git a/Week2/Homework-Week2/7-length_of_string.js b/Week2/Homework-Week2/7-length_of_string.js new file mode 100644 index 000000000..33c26ff3b --- /dev/null +++ b/Week2/Homework-Week2/7-length_of_string.js @@ -0,0 +1,4 @@ +let myString = "this is a test"; +console.log(myString); +console.log("The length of myString is: " + myString.length); +console.log("\n"); \ No newline at end of file diff --git a/Week2/Homework-Week2/8-comparing_with_typeof.js b/Week2/Homework-Week2/8-comparing_with_typeof.js new file mode 100644 index 000000000..76ce6d701 --- /dev/null +++ b/Week2/Homework-Week2/8-comparing_with_typeof.js @@ -0,0 +1,29 @@ +let k = 12; +let l = "Hi"; +let m = true; +let n = ["Hello", "Hi"]; +console.log("The value of my variable k is: " + k); +console.log("The value of my variable l is: " + l); +console.log("The value of my variable m is: " + m); +console.log("The value of my variable n is: " + n); +console.log("I think the type of 'k' is 'number'\n" + +"The type of 'l' is 'string'\nThe type of 'm' is 'boolean'\nThe type of 'n' is 'object'"); +if (typeof k == typeof l) { + console.log('k and l SAME TYPE'); +} +if (typeof k == typeof m) { + console.log('k and m SAME TYPE'); +} +if (typeof k == typeof n) { + console.log('k and n SAME TYPE'); +} +if (typeof l == typeof m) { + console.log('l and m SAME TYPE'); +} +if (typeof l == typeof n) { + console.log('l and n SAME TYPE'); +} +if (typeof m == typeof n) { + console.log('m and n SAME TYPE'); +} +console.log("\n"); \ No newline at end of file diff --git a/Week2/Homework-Week2/9-using_remainder.js b/Week2/Homework-Week2/9-using_remainder.js new file mode 100644 index 000000000..e7970a8c9 --- /dev/null +++ b/Week2/Homework-Week2/9-using_remainder.js @@ -0,0 +1,7 @@ +let i = 7; +console.log("The value of variable i is 7"); +i = i%3; +console.log("The value of variable i is now " + i + " after 'i = i%3;' operation"); +console.log("% operator returns module of two numbers"); +console.log("% operator is a divison remainder"); +console.log("\n"); \ No newline at end of file diff --git a/Week3/Homework-Week3/1- moving_chars_in_a_string.js b/Week3/Homework-Week3/1- moving_chars_in_a_string.js new file mode 100644 index 000000000..a8652f60a --- /dev/null +++ b/Week3/Homework-Week3/1- moving_chars_in_a_string.js @@ -0,0 +1,6 @@ +let myString = "hello,this,is,a,difficult,to,read,sentence"; +console.log(myString); +console.log(myString.length); +let newString = myString.replace(/,/g, " "); // use regular expression to replase all matches +myString = newString; +console.log(myString); \ No newline at end of file diff --git a/Week3/Homework-Week3/2- some_arrays.js b/Week3/Homework-Week3/2- some_arrays.js new file mode 100644 index 000000000..2db44adcb --- /dev/null +++ b/Week3/Homework-Week3/2- some_arrays.js @@ -0,0 +1,16 @@ +let favoriteAnimals = ["blowfish", "capricorn", "giraffe"]; +favoriteAnimals.push("turtle"); +console.log(favoriteAnimals); +favoriteAnimals.splice(1, 0, "meerkat"); // adding meerkat to array +console.log("The new value of array will be [ 'blowfish', 'meerkat', 'capricorn', 'giraffe', 'turtle' ]"); +console.log(favoriteAnimals); +console.log("The array has a length of: ", favoriteAnimals.length); +favoriteAnimals.splice(3, 1); //delete giraffe +console.log(favoriteAnimals); +var indexOfMeerkat; +for (let i = 0; i < favoriteAnimals.length; i++) { + if (favoriteAnimals[i] == "meerkat") { + indexOfMeerkat = i; + } +} +console.log("The item you are looking for is at index: ", indexOfMeerkat); \ No newline at end of file diff --git a/Week3/Homework-Week3/More Javascript/1-function_sum.js b/Week3/Homework-Week3/More Javascript/1-function_sum.js new file mode 100644 index 000000000..326127615 --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/1-function_sum.js @@ -0,0 +1,6 @@ +var sum = sumFunction(4, 5, 7); +console.log(sum); +function sumFunction(a, b, c) { + let sum = a + b + c; + return sum; +} diff --git a/Week3/Homework-Week3/More Javascript/10-using_join_split_alice.js b/Week3/Homework-Week3/More Javascript/10-using_join_split_alice.js new file mode 100644 index 000000000..768d11c4d --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/10-using_join_split_alice.js @@ -0,0 +1,23 @@ + + +const myVehicles = ["car", "motorbike", "caravan", "bike"]; + +function vehicles(arrays) { + // const myVehicles = ["car", "motorbike", "caravan", "bike"]; + const newMyVehicles = arrays.join("s, "); + const head = newMyVehicles.split(",").slice(0, -1) ; + const tail = arrays[arrays.length -1]; + // newMyVehicles.slice(0, -2); + console.log(head); + console.log(tail); + // let i; + // let advertisementService = ""; + // for (i = 0; i < myVehicles.length; i++) { + // if (i == 3) { + // advertisementService += "and "; + // } + // advertisementService += myVehicles[i] + "s, "; + // } + console.log(`Amazing Bibi's Garage, we service ${head} and ${tail}s.`); +} +vehicles(myVehicles); \ No newline at end of file diff --git a/Week3/Homework-Week3/More Javascript/11-using_join_split_alice2.js b/Week3/Homework-Week3/More Javascript/11-using_join_split_alice2.js new file mode 100644 index 000000000..4bd6828f5 --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/11-using_join_split_alice2.js @@ -0,0 +1,21 @@ +const myVehicles = ["car", "motorbike", "caravan", "bike", "suv"]; + +function vehicles(arrays) { + // const myVehicles = ["car", "motorbike", "caravan", "bike"]; + const newMyVehicles = arrays.join("s, "); + const head = newMyVehicles.split(",").slice(0, -1) ; + const tail = arrays[arrays.length -1]; + // newMyVehicles.slice(0, -2); + console.log(head); + console.log(tail); + // let i; + // let advertisementService = ""; + // for (i = 0; i < myVehicles.length; i++) { + // if (i == 3) { + // advertisementService += "and "; + // } + // advertisementService += myVehicles[i] + "s, "; + // } + console.log(`Amazing Bibi's Garage, we service ${head} and ${tail}s.`); +} +vehicles(myVehicles); \ No newline at end of file diff --git a/Week3/Homework-Week3/More Javascript/12-declaring_empty_object.js b/Week3/Homework-Week3/More Javascript/12-declaring_empty_object.js new file mode 100644 index 000000000..ff5886e15 --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/12-declaring_empty_object.js @@ -0,0 +1 @@ +var hyfTeachers = {}; \ No newline at end of file diff --git a/Week3/Homework-Week3/More Javascript/13-adding_property_and_values_to_an_object.js b/Week3/Homework-Week3/More Javascript/13-adding_property_and_values_to_an_object.js new file mode 100644 index 000000000..4d683c3aa --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/13-adding_property_and_values_to_an_object.js @@ -0,0 +1,3 @@ +const hyfTeachers = new Object; +hyfTeachers.teachers = "Josha, Sander, Unmesh, Yash, Nouran, Joost"; +console.log(hyfTeachers.teachers); \ No newline at end of file diff --git a/Week3/Homework-Week3/More Javascript/14-adding_property_and_values_to_an_object2.js b/Week3/Homework-Week3/More Javascript/14-adding_property_and_values_to_an_object2.js new file mode 100644 index 000000000..775bc1cfa --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/14-adding_property_and_values_to_an_object2.js @@ -0,0 +1,4 @@ +const hyfTeachers = new Object; +hyfTeachers.teachers = "Html-Css, Sander, Unmesh, Yash, Nouran, Joost"; +hyfTeachers.languages = "Html-Css, Html-Css, CLI, GIT, JavaScript"; +console.log(hyfTeachers); \ No newline at end of file diff --git a/Week3/Homework-Week3/More Javascript/15-comparing_arrays_and_assigned_arrays.js b/Week3/Homework-Week3/More Javascript/15-comparing_arrays_and_assigned_arrays.js new file mode 100644 index 000000000..233dcb45d --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/15-comparing_arrays_and_assigned_arrays.js @@ -0,0 +1,8 @@ +let x = [1, 2, 3]; +let y = [1, 2, 3]; +let z = y; + +x == y ? console.log("x array is equal to y array") : console.log("x array is not equal to y array"); +x === y ? console.log("Type of x array is equal to type of y array") : console.log("Type of x array is not equal to type of y array"); +z == y ? console.log("z array is equal to y array") : console.log("z array is not equal to y array"); +z == x ? console.log("z array is equal to x array") : console.log("z array is not equal to x array"); \ No newline at end of file diff --git a/Week3/Homework-Week3/More Javascript/16-comparing_objects_and_assigned_objects.js b/Week3/Homework-Week3/More Javascript/16-comparing_objects_and_assigned_objects.js new file mode 100644 index 000000000..71e6c70e9 --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/16-comparing_objects_and_assigned_objects.js @@ -0,0 +1,11 @@ +var o1 = { foo: "bar" }; +var o2 = { foo: "bar" }; +var o3 = o2; // We can't change the order like o3 = o2 + +console.log(o3); + +o2.too = "far"; +console.log(o3); // Changing o2 changes o3 + +o1.soo = "car"; +console.log(o3); // Changing o1 does not change o3 diff --git a/Week3/Homework-Week3/More Javascript/17-example_typeof_typeof.js b/Week3/Homework-Week3/More Javascript/17-example_typeof_typeof.js new file mode 100644 index 000000000..de999d5ce --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/17-example_typeof_typeof.js @@ -0,0 +1,7 @@ +let bar = 42; +console.log(typeof typeof bar); /* It returns string because +the type of bar is "number" and this is a string. So type of "number" +is being string*/ + +let typeOfBar = typeof bar; +console.log(typeOfBar); \ No newline at end of file diff --git a/Week3/Homework-Week3/More Javascript/2-function_color.js b/Week3/Homework-Week3/More Javascript/2-function_color.js new file mode 100644 index 000000000..7a3a602e1 --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/2-function_color.js @@ -0,0 +1,4 @@ +function colorCar(color) { + let car = "a " + color + " car"; + return car; +} \ No newline at end of file diff --git a/Week3/Homework-Week3/More Javascript/3-objects_and_functions.js b/Week3/Homework-Week3/More Javascript/3-objects_and_functions.js new file mode 100644 index 000000000..800983899 --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/3-objects_and_functions.js @@ -0,0 +1,11 @@ +var personInfo = { + name: "Smith", + surName: "Ailey", + age: 34 +}; + +myFunction(personInfo); + +function myFunction(info) { + console.log(info); +} diff --git a/Week3/Homework-Week3/More Javascript/4-function_with_condition.js b/Week3/Homework-Week3/More Javascript/4-function_with_condition.js new file mode 100644 index 000000000..834a32388 --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/4-function_with_condition.js @@ -0,0 +1,15 @@ +var result = vehicleType("red", 2); +console.log(result); + +function vehicleType(color, code) { + //let a = color; + //let b = code; + if (code == 1) { + return "a " + color + " car"; + } else if (code == 2) { + return "a " + color + " motorbike"; + } else { + return "Select 1 or 2"; + } + +} diff --git a/Week3/Homework-Week3/More Javascript/5-compare_primitive_data.js b/Week3/Homework-Week3/More Javascript/5-compare_primitive_data.js new file mode 100644 index 000000000..a7cedeb23 --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/5-compare_primitive_data.js @@ -0,0 +1 @@ +console.log(3 === 3 ? "Yes" : "No"); \ No newline at end of file diff --git a/Week3/Homework-Week3/More Javascript/6-function_with_two_conditions.js b/Week3/Homework-Week3/More Javascript/6-function_with_two_conditions.js new file mode 100644 index 000000000..7b6ea12a9 --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/6-function_with_two_conditions.js @@ -0,0 +1,22 @@ +console.log(vehicleType("black", 1, 0)); + +function vehicleType(color, code, age) { + //let a = color; + //let b = code; + if (code == 1) { + vehicle = "car"; + } else if (code == 2) { + vehicle = "motorbike"; + } else { + return "Select 1 or 2"; + } + + if (age == 0) { + status = "new"; + } else { + status = "used"; + } + + return "a " + color + " " + status + " car"; + +} diff --git a/Week3/Homework-Week3/More Javascript/7-declaring_an_array.js b/Week3/Homework-Week3/More Javascript/7-declaring_an_array.js new file mode 100644 index 000000000..f5db6bfad --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/7-declaring_an_array.js @@ -0,0 +1,2 @@ +var vehicles = ["automobile", "caravan", "bike", "suv", "motorbike"]; +console.log("Vehicles list: ", vehicles); diff --git a/Week3/Homework-Week3/More Javascript/8-obtain_an_element_of_array.js b/Week3/Homework-Week3/More Javascript/8-obtain_an_element_of_array.js new file mode 100644 index 000000000..335d7897c --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/8-obtain_an_element_of_array.js @@ -0,0 +1,2 @@ +var vehicles = ["automobile", "caravan", "bike", "suv", "motorbike"]; +console.log("The third element of vehicles ", vehicles[2]); \ No newline at end of file diff --git a/Week3/Homework-Week3/More Javascript/9-using_Arguments_with_functions.js b/Week3/Homework-Week3/More Javascript/9-using_Arguments_with_functions.js new file mode 100644 index 000000000..47d93aefa --- /dev/null +++ b/Week3/Homework-Week3/More Javascript/9-using_Arguments_with_functions.js @@ -0,0 +1,19 @@ +console.log(vehicles("yellow", 3, 3)); + +function vehicles(color, code, age) { + let myVehicles = ["car", "motorbike", "caravan", "bike"]; + let selectedVehicle; + let ageOfVehicle; + let i; + for (i = 0; i < 4; i++) { + if (code == i) { + selectedVehicle = myVehicles[i]; + } + } + if (age > 1) { + ageOfVehicle = " old "; + } else { + ageOfVehicle = " new "; + } + return "a " + color + ageOfVehicle + selectedVehicle; +}