From 880346afaba4bfc7cd212887da6bc6d13949049e Mon Sep 17 00:00:00 2001 From: Riam Alali <48811666+RiamAlali@users.noreply.github.com> Date: Sun, 5 May 2019 14:01:45 +0200 Subject: [PATCH 01/17] Add files via upload --- week2homework.js | 121 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 week2homework.js diff --git a/week2homework.js b/week2homework.js new file mode 100644 index 000000000..7d2335311 --- /dev/null +++ b/week2homework.js @@ -0,0 +1,121 @@ +//1 +let EnglishGreeting = "Hello world!"; +console.log (EnglishGreeting) +let ArabicGreeting = "مرحباً بالعالم"; +console.log (ArabicGreeting) +let ItalianGreeting = "Ciao Mondo!"; +console.log (ItalianGreeting) +let TurkishGreeting = "Selam Dünya!"; +console.log (TurkishGreeting) +let DutchGreeting = "Hallo Wereld!"; +console.log (DutchGreeting) + +//2 +console.log ('I\'m awesome'); + +//3 +let x ; +console.log ("the value of my variable x will be:EvenNumber"); +console.log (x); +x = 8 ; +console.log ("the value of my variable x will be:EvenNumber"); +console.log (x) + +//4 +let y = "HackYourFuture" +console.log ("the value of the string is "+"HackYourFuture") +console.log (y) +y = "HYF" +console.log ("the value of the string is "+"HYF") +console.log (y) + +//5 +let z = 7.25; +console.log(z); +let a = (Math.round(z)); +console.log(a); + +let highest; +if (z>a){ + highest=z; +} +else{ + highest=a; +} +console.log(highest); + + +//6 +let FavoriteAnimals = [ ]; //6.1 +console.log("the value of my array is : Empty."); //6.2 +console.log(FavoriteAnimals); //6.3 +let MyFavoriteAnimals = [ 'Deer' , 'Horse' , 'Koala' ]; //6.4 +console.log (MyFavoriteAnimals); //6.5 +let NewMyFavoriteAnimals = MyFavoriteAnimals.concat(['baby pig']); //6.6 +console.log (NewMyFavoriteAnimals); //6.7 + +//7 +let myString = "this is a test"; +console.log(myString); +console.log(myString.length); + +//8 +let type1 = 21 ; +console.log ("The value of my variable type1 is: " + type1); +console.log (typeof(type1)); +let type2 = ['HTML', 'CSS'] ; +console.log ("The value of my variable type2 is: " + type2); +console.log (typeof(type2)); +let type3 = " Hello JavaScript " ; +console.log ("The value of my variable type3 is: " + type3); +console.log (typeof(type3)); +let type4 = "Class21" ; +console.log ("The value of my variable type4 is: " + type4); +console.log (typeof(type4)); + +//8.5 +if (typeof(type1)===typeof(type2)) +{console.log('type1 and type2 are SameType');} +else {console.log('type1 and type2 are NOT SameType');} + +if (typeof(type1)===typeof(type3)) +{console.log('type1 and type3 are SameType');} +else {console.log('type1 and type3 are NOT SameType');} + +if (typeof(type1)===typeof(type4)) +{console.log('type1 and type4 are SameType');} +else {console.log('type1 and type4 are NOT SameType');} + +if (typeof(type2)===typeof(type3)) +{console.log('type2 and type3 are SameType');} +else {console.log('type2 and type3 are NOT SameType');} + +if (typeof(type2)===typeof(type4)) +{console.log('type2 and type4 are SameType');} +else {console.log('type2 and type4 are NOT SameType');} + +if (typeof(type3)===typeof(type4)) +{console.log('type3 and type4 are SameType');} +else {console.log('type3 and type4 are NOT SameType');} + + + + + +//9 +let X = 7 ; +X = X % 3; +console.log(X = X % 3); +console.log(X %= 3); +console.log(X); + +//10.1 +let multipleTypesArray = ['class', 21 , true]; +console.log(typeof(multipleTypesArray[0])); +console.log(typeof(multipleTypesArray[1])); +console.log(typeof(multipleTypesArray[2])); + +//10.2 +let x1 = 6/0; +let y1 = 10/0; +x1 === y1? console.log('Yes') : console.log('No'); From ae54b78d61fa23b5334ac9f70707af1d57dc71c7 Mon Sep 17 00:00:00 2001 From: Riam Alali <48811666+RiamAlali@users.noreply.github.com> Date: Fri, 10 May 2019 05:38:57 +0200 Subject: [PATCH 02/17] Add files via upload --- task1.js | 12 ++++++++++ task10.js | 14 ++++++++++++ task2.js | 7 ++++++ task3.js | 19 ++++++++++++++++ task4.js | 23 ++++++++++++++++++++ task5.js | 27 +++++++++++++++++++++++ task6.js | 16 ++++++++++++++ task7.js | 9 ++++++++ task8.js | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ task9.js | 8 +++++++ 10 files changed, 200 insertions(+) create mode 100644 task1.js create mode 100644 task10.js create mode 100644 task2.js create mode 100644 task3.js create mode 100644 task4.js create mode 100644 task5.js create mode 100644 task6.js create mode 100644 task7.js create mode 100644 task8.js create mode 100644 task9.js diff --git a/task1.js b/task1.js new file mode 100644 index 000000000..8807063b8 --- /dev/null +++ b/task1.js @@ -0,0 +1,12 @@ +//1 write a console.log statement saying "Hello World!" for each language that you know. + +let EnglishGreeting = "Hello world!"; +console.log (EnglishGreeting) +let ArabicGreeting = "مرحباً بالعالم"; +console.log (ArabicGreeting) +let ItalianGreeting = "Ciao Mondo!"; +console.log (ItalianGreeting) +let TurkishGreeting = "Selam Dünya!"; +console.log (TurkishGreeting) +let DutchGreeting = "Hallo Wereld!"; +console.log (DutchGreeting); \ No newline at end of file diff --git a/task10.js b/task10.js new file mode 100644 index 000000000..a7746e78e --- /dev/null +++ b/task10.js @@ -0,0 +1,14 @@ +/* 10. Write a program to answer the following questions: +10.1 Can you store multiple types in an array? Numbers and strings? Make an example that illustrates your answer. +10.2 Can you compare infinities? (Not in Eyad's world) - does 6/0 === 10/0? How can you test this? +10.3 Add console.log statements to the above program in which you show that you understand the concepts (just like you've done in the above assignments).*/ + +let multipleTypesArray = ['class', 21 , true]; +console.log(typeof(multipleTypesArray[0])); +console.log(typeof(multipleTypesArray[1])); +console.log(typeof(multipleTypesArray[2])); + +//10.2 +let x1 = 6/0; +let y1 = 10/0; +x1 === y1? console.log('Yes') : console.log('No'); diff --git a/task2.js b/task2.js new file mode 100644 index 000000000..58df526ed --- /dev/null +++ b/task2.js @@ -0,0 +1,7 @@ +/*2 cosider the following code: console.log('I'm awesome'); +copy the code in your .js file and run it. +you will see that you get a syntaxError. +find a solution for this error. +Hint:read the error message carefully, it also gives an indication of where the problem is.*/ + +console.log ('I\'m awesome'); \ No newline at end of file diff --git a/task3.js b/task3.js new file mode 100644 index 000000000..d8de3fe05 --- /dev/null +++ b/task3.js @@ -0,0 +1,19 @@ +//3 Declare a variable x and initialize it with an integer, using these steps: +//3.1 First, Declare your variable x (do not initialize it yet) +//3.2 add a console.log statement that explains in words what you think the value of x is. +//3.3 add a console.log statement that logs the value of x. +//3.4 Now initialize your variable x with an integer. +//3.5 Next, add console.log statement that explains what you think the value of x is. +//3.6 add a console log staement that logs the value of x. + +let x ; + +console.log ("the value of my variable x will be:an Integer"); + +console.log (x); + +x = 8 ; + +console.log ("the value of my variable x will be:an Integer"); + +console.log (x); \ No newline at end of file diff --git a/task4.js b/task4.js new file mode 100644 index 000000000..3023b7057 --- /dev/null +++ b/task4.js @@ -0,0 +1,23 @@ +//4 Declare a variable y and assign a string to it. +//4.1 Write a console.log statement in which you explain in words what you think the value of the string is. +//4.2 Now console.log the variable y. +//4.3 Now assign a new string to the variable y. +//4.4 Write a console.log statement that explains in words what you think will be logged to the console. +//Now console.lg y again + +let y = "HackYourFuture"; + + +console.log ("the value of the string is: " + "HackYourFuture"); + + +console.log (y); + + +y = "HYF"; + + +console.log ("the value of the string is: " + "HYF"); + + +console.log (y); diff --git a/task5.js b/task5.js new file mode 100644 index 000000000..16ecdd900 --- /dev/null +++ b/task5.js @@ -0,0 +1,27 @@ +//5 How do you round the number 7.25 to the nearest integer, +//5.1 Declare a variable z and assign the number 7.25 to it. +//5.2 Console.log z. +//5.3 Declare another variable a that has the value of z but rounded to the nearest integer. +//5.4 console.log a. +//5.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. +//5.6 console.log the highest value. + +let z = 7.25; + +console.log(z); + +let a = (Math.round(z)); + +console.log(a); + +let highest; +if (z > a) { + highest = z ; +} +else { + highest = a ; +}; + +console.log(highest); + +//You can also use math.max, but this solution is fine \ No newline at end of file diff --git a/task6.js b/task6.js new file mode 100644 index 000000000..bca72b897 --- /dev/null +++ b/task6.js @@ -0,0 +1,16 @@ +//6 +let favoriteAnimals = [ ]; + +console.log("the value of my array is : Empty."); + +console.log(favoriteAnimals); + +let myFavoriteAnimals = [ 'Deer' , 'Horse' , 'Koala' ]; + +console.log (myFavoriteAnimals); + +let newMyFavoriteAnimals = myFavoriteAnimals.concat(['baby pig']); + +console.log (newMyFavoriteAnimals); + +// you can also use myFavoriteAnimals.push('baby pig'); Which might be an easier solution. diff --git a/task7.js b/task7.js new file mode 100644 index 000000000..ef7d1509d --- /dev/null +++ b/task7.js @@ -0,0 +1,9 @@ +/* 7. More strings +Let's consider the following string: let myString = "this is a test". +7.1 Add the string to your file and console.log it. +7.2 Find a way to get the length of myString. +7.3 console.log the length of myString.*/ + +let myString = "this is a test"; +console.log(myString); +console.log(myString.length); diff --git a/task8.js b/task8.js new file mode 100644 index 000000000..ff7e61cf4 --- /dev/null +++ b/task8.js @@ -0,0 +1,65 @@ +/* 8. Write a program that checks the types of two variables and prints out SAME TYPE if they are the same type. +8.1 First declare at least four variables and assign them different data types. +8.2 For each variable write a console.log statement that logs the value +8.3 Now write a console.log statement wherein you first explain in words what you think the type of your variables is. +8.4 Now use typeof to log the actual type of your variables. +8.5 Now compare the types of your different variables with one another. +8.6 Make sure to also show a message when the variables you are comparing are not the same type.*/ + + +let type1 = 21 ; +console.log ("The value of my variable type1 is: " + type1); +console.log (typeof(type1)); +let type2 = ['HTML', 'CSS'] ; +console.log ("The value of my variable type2 is: " + type2); +console.log (typeof(type2)); +let type3 = " Hello JavaScript " ; +console.log ("The value of my variable type3 is: " + type3); +console.log (typeof(type3)); +let type4 = "Class21" ; +console.log ("The value of my variable type4 is: " + type4); +console.log (typeof(type4)); + +//8.5 +if (typeof(type1)===typeof(type2)) { + console.log('type1 and type2 are SameType'); +} +else { + console.log('type1 and type2 are NOT SameType'); +} + +if (typeof(type1)===typeof(type3)) { + console.log('type1 and type3 are SameType'); +} +else { + console.log('type1 and type3 are NOT SameType'); +} + +if (typeof(type1)===typeof(type4)) { + console.log('type1 and type4 are SameType'); +} +else { + console.log('type1 and type4 are NOT SameType'); +} + +if (typeof(type2)===typeof(type3)) { + console.log('type2 and type3 are SameType'); +} +else { + console.log('type2 and type3 are NOT SameType'); +} + +if (typeof(type2)===typeof(type4)) { + console.log('type2 and type4 are SameType'); +} +else { + console.log('type2 and type4 are NOT SameType'); +} + +if (typeof(type3)===typeof(type4)) { + console.log('type3 and type4 are SameType'); +} +else { + console.log('type3 and type4 are NOT SameType'); +} + diff --git a/task9.js b/task9.js new file mode 100644 index 000000000..d88334482 --- /dev/null +++ b/task9.js @@ -0,0 +1,8 @@ +/* 9. If x equals 7, and the only other statement is x = x % 3, what would be the new value of x? +9.1 Add at least 3 console.log statements in which you show that you understand what % does.*/ + +let x = 7 ; +x = x % 3; +console.log(x = x % 3); +console.log(x %= 3); +console.log(x); From a92d2977c5782aac293650f4330ec0071e5ac34f Mon Sep 17 00:00:00 2001 From: Riam Date: Wed, 15 May 2019 10:25:57 +0200 Subject: [PATCH 03/17] add week3 --- Week3/.DS_Store | Bin 0 -> 6148 bytes Week3/More-JS-1.js | 8 ++++++ Week3/More-JS-12.js | 3 +++ Week3/More-JS-13-14.js | 17 ++++++++++++ Week3/More-JS-15.js | 14 ++++++++++ Week3/More-JS-16.js | 15 +++++++++++ Week3/More-JS-17.js | 12 +++++++++ Week3/More-JS-2.js | 6 +++++ Week3/More-JS-3.js | 22 +++++++++++++++ Week3/More-JS-4.js | 15 +++++++++++ Week3/More-JS-5.js | 9 +++++++ Week3/More-JS-6.js | 12 +++++++++ Week3/More-JS-7-8-9-10-11.js | 51 +++++++++++++++++++++++++++++++++++ Week3/strings-arrays.js | 37 +++++++++++++++++++++++++ 14 files changed, 221 insertions(+) create mode 100644 Week3/.DS_Store create mode 100644 Week3/More-JS-1.js create mode 100644 Week3/More-JS-12.js create mode 100644 Week3/More-JS-13-14.js create mode 100644 Week3/More-JS-15.js create mode 100644 Week3/More-JS-16.js create mode 100644 Week3/More-JS-17.js create mode 100644 Week3/More-JS-2.js create mode 100644 Week3/More-JS-3.js create mode 100644 Week3/More-JS-4.js create mode 100644 Week3/More-JS-5.js create mode 100644 Week3/More-JS-6.js create mode 100644 Week3/More-JS-7-8-9-10-11.js create mode 100644 Week3/strings-arrays.js diff --git a/Week3/.DS_Store b/Week3/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T02) { + console.log("a " + color + " used car") + }} + vehicle("blue", 1, 5); diff --git a/Week3/More-JS-7-8-9-10-11.js b/Week3/More-JS-7-8-9-10-11.js new file mode 100644 index 000000000..852315f93 --- /dev/null +++ b/Week3/More-JS-7-8-9-10-11.js @@ -0,0 +1,51 @@ + +//7 Make a list of vehicles, you can add "motorbike", "caravan", "bike", or more. +let listOfVehicles = ["motorbike","caravan","bike"]; + +//8 How do you get the third element from that list? +console.log(listOfVehicles[2]); + + + + +/*9 Change the function vehicle to use the list of question 7. + So that vehicle("green", 3, 1) prints "a green new bike".*/ +function Vehicles(color,code,age){ +if(code=listOfVehicles[2] && age<2){ + console.log("a " + color + " new bike") +} +else { + console.log("a " + color + "old bike") +}; +} +Vehicles("green", 3, 1); + + +/*10 Use the list of vehicles to write an advertisement. +So that it prints something like: +"Amazing Joe's Garage, we service cars, motorbikes, caravans and bikes.". +(Hint: use a for loop.) +Hint, the output should be correct English with all the punctuation in place +(that's the challenge). So plurals for the vehicle types, commas followed by a single space, +the word and to replace the final comma and closed off by a period. */ + +//11 What if you add one more vehicle to the list, can you have that added to the advertisement without changing the code for question 10? + +listOfVehicles = ["motorbike","caravan","bike","car"]; + +function advertisement(listOfVehicles){ + for(let i=0; i Date: Wed, 15 May 2019 11:21:46 +0200 Subject: [PATCH 04/17] Delete .DS_Store --- Week3/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Week3/.DS_Store diff --git a/Week3/.DS_Store b/Week3/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Wed, 15 May 2019 11:21:55 +0200 Subject: [PATCH 05/17] Delete More-JS-1.js --- Week3/More-JS-1.js | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 Week3/More-JS-1.js diff --git a/Week3/More-JS-1.js b/Week3/More-JS-1.js deleted file mode 100644 index 4770119f1..000000000 --- a/Week3/More-JS-1.js +++ /dev/null @@ -1,8 +0,0 @@ - - -//1 Create a function that takes 3 arguments and returns the sum of the these arguments. -function sum(a, b, c) { - return a + b + c; - } - let result = sum(1, 2, 3); - console.log(result); \ No newline at end of file From 8c22a3d747492b195f4d8fccdee689161c04823d Mon Sep 17 00:00:00 2001 From: Riam Alali <48811666+RiamAlali@users.noreply.github.com> Date: Wed, 15 May 2019 11:22:03 +0200 Subject: [PATCH 06/17] Delete More-JS-12.js --- Week3/More-JS-12.js | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 Week3/More-JS-12.js diff --git a/Week3/More-JS-12.js b/Week3/More-JS-12.js deleted file mode 100644 index 646da2c55..000000000 --- a/Week3/More-JS-12.js +++ /dev/null @@ -1,3 +0,0 @@ - -//12 Create an empty object. -let emptyObj = {}; \ No newline at end of file From a221ead5ca77d9c609ddcd0b9751646d0b92b3b8 Mon Sep 17 00:00:00 2001 From: Riam Alali <48811666+RiamAlali@users.noreply.github.com> Date: Wed, 15 May 2019 11:22:10 +0200 Subject: [PATCH 07/17] Delete More-JS-13-14.js --- Week3/More-JS-13-14.js | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 Week3/More-JS-13-14.js diff --git a/Week3/More-JS-13-14.js b/Week3/More-JS-13-14.js deleted file mode 100644 index 6550c6f69..000000000 --- a/Week3/More-JS-13-14.js +++ /dev/null @@ -1,17 +0,0 @@ - -//13 Create an object that contains the teachers that you have had so far for the different modules. -//14 Add a property to the object you just created that contains the languages that they have taught you. - - -let teachers = { - Philip : "HTML & CSS", - Hardit : "CLI", - Unmesh : "Git", - Sander : "JS" -} -console.log(teachers); - - - - - From 769f2d8506997800c240f408494ae914006cd0f3 Mon Sep 17 00:00:00 2001 From: Riam Alali <48811666+RiamAlali@users.noreply.github.com> Date: Wed, 15 May 2019 11:22:18 +0200 Subject: [PATCH 08/17] Delete More-JS-15.js --- Week3/More-JS-15.js | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 Week3/More-JS-15.js diff --git a/Week3/More-JS-15.js b/Week3/More-JS-15.js deleted file mode 100644 index dbfb57da2..000000000 --- a/Week3/More-JS-15.js +++ /dev/null @@ -1,14 +0,0 @@ - -//15 Write some code to test two arrays for equality using == and ===. Test the following: -/* let x = [1, 2, 3]; -let y = [1, 2, 3]; -let z = y; -What do you think will happen with x == y, x === y and z == y and z == x? Prove it! -*/ -let x = [1, 2, 3]; -let y = [1, 2, 3]; -let z = y; -console.log(x==y); -console.log(x===y); -console.log(z==y); // true -console.log(z===x); From ee5ec259fa6c6dbe61b9ad579c962dc044625902 Mon Sep 17 00:00:00 2001 From: Riam Alali <48811666+RiamAlali@users.noreply.github.com> Date: Wed, 15 May 2019 11:22:26 +0200 Subject: [PATCH 09/17] Delete More-JS-16.js --- Week3/More-JS-16.js | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 Week3/More-JS-16.js diff --git a/Week3/More-JS-16.js b/Week3/More-JS-16.js deleted file mode 100644 index be90f50b0..000000000 --- a/Week3/More-JS-16.js +++ /dev/null @@ -1,15 +0,0 @@ - -//16 -/* Take a look at the following code: - -let o1 = { foo: "bar" }; -let o2 = { foo: "bar" }; -let o3 = o2; - -Show that changing o2 changes o3 (or not) and changing o1 changes o3(or not). -Does the order that you assign (o3 = o2 or o2 = o3) matter? -*/ -let o1 = { foo: "bar" }; -let o2 = { foo: "bar" }; -let o3 = o2; -// didn't work so far \ No newline at end of file From f147d042ece05c1f5f6b18813a025dc2336e9f14 Mon Sep 17 00:00:00 2001 From: Riam Alali <48811666+RiamAlali@users.noreply.github.com> Date: Wed, 15 May 2019 11:22:34 +0200 Subject: [PATCH 10/17] Delete More-JS-17.js --- Week3/More-JS-17.js | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 Week3/More-JS-17.js diff --git a/Week3/More-JS-17.js b/Week3/More-JS-17.js deleted file mode 100644 index 548197ab7..000000000 --- a/Week3/More-JS-17.js +++ /dev/null @@ -1,12 +0,0 @@ - -//17 What does the following code return? (And why?) -/* -let bar = 42; -typeof typeof bar; -‘Coerce' means to try to change - so coercing var x = '6' to number means trying to change the type to number temporarily. -*/ -let bar = 42; -typeof typeof bar; -console.log(typeof bar); // number -console.log(typeof typeof bar); // type of number is string - From 62e1263f53fb16f604c92ddf9356a67ce2993909 Mon Sep 17 00:00:00 2001 From: Riam Alali <48811666+RiamAlali@users.noreply.github.com> Date: Wed, 15 May 2019 11:22:41 +0200 Subject: [PATCH 11/17] Delete More-JS-2.js --- Week3/More-JS-2.js | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 Week3/More-JS-2.js diff --git a/Week3/More-JS-2.js b/Week3/More-JS-2.js deleted file mode 100644 index ed0159ff8..000000000 --- a/Week3/More-JS-2.js +++ /dev/null @@ -1,6 +0,0 @@ - -//2 Create a function named colorCar that receives a color, and prints out, 'a red car' for example. -function colorCar(color){ - return "a " + color + " car"; -} -console.log(colorCar("red")); \ No newline at end of file From b0294302a89de6fd0589a069b284956abed1564d Mon Sep 17 00:00:00 2001 From: Riam Alali <48811666+RiamAlali@users.noreply.github.com> Date: Wed, 15 May 2019 11:22:49 +0200 Subject: [PATCH 12/17] Delete More-JS-3.js --- Week3/More-JS-3.js | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 Week3/More-JS-3.js diff --git a/Week3/More-JS-3.js b/Week3/More-JS-3.js deleted file mode 100644 index 4151b2f1b..000000000 --- a/Week3/More-JS-3.js +++ /dev/null @@ -1,22 +0,0 @@ - -/*3 Create an object and a function that takes the object as a parameter and - prints out all of its properties and values.*/ -let materials= [ - { - week1 : "HTML", - }, - { - week2 : "CSS", - }, - { - week3 : "git", - } -] -function course(materials){ - for(let i=0; i Date: Wed, 15 May 2019 11:22:56 +0200 Subject: [PATCH 13/17] Delete More-JS-4.js --- Week3/More-JS-4.js | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 Week3/More-JS-4.js diff --git a/Week3/More-JS-4.js b/Week3/More-JS-4.js deleted file mode 100644 index 433b5aae4..000000000 --- a/Week3/More-JS-4.js +++ /dev/null @@ -1,15 +0,0 @@ - -//4 Create a function named vehicleType that receives a color, and a code, 1 for car, 2 for motorbike. And prints 'a blue motorbike' for example when called as vehicleType("blue", 2) - -function vehicleType(color,code){ - if (code === 1) - console.log("a " + color + " car") - - else if - (code===2) - console.log("a " + color + " motorbike"); - - -} -vehicleType("blue",2); - From 7c24d808514b385f800809cfd92e1dc4fe994fad Mon Sep 17 00:00:00 2001 From: Riam Alali <48811666+RiamAlali@users.noreply.github.com> Date: Wed, 15 May 2019 11:23:04 +0200 Subject: [PATCH 14/17] Delete More-JS-5.js --- Week3/More-JS-5.js | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 Week3/More-JS-5.js diff --git a/Week3/More-JS-5.js b/Week3/More-JS-5.js deleted file mode 100644 index 8295e47e8..000000000 --- a/Week3/More-JS-5.js +++ /dev/null @@ -1,9 +0,0 @@ - -//5 Can you write the following without the if statement, but with just as a single line with console.log(...);? -/* if (3 === 3) { - console.log("yes"); -} else { - console.log("no"); -} */ - -3 === 3 ? console.log("yes"): console.log("no"); \ No newline at end of file From 3297e1c0970f510ae37baf8e296e67df21c3af1a Mon Sep 17 00:00:00 2001 From: Riam Alali <48811666+RiamAlali@users.noreply.github.com> Date: Wed, 15 May 2019 11:23:13 +0200 Subject: [PATCH 15/17] Delete More-JS-6.js --- Week3/More-JS-6.js | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 Week3/More-JS-6.js diff --git a/Week3/More-JS-6.js b/Week3/More-JS-6.js deleted file mode 100644 index 6675d1a84..000000000 --- a/Week3/More-JS-6.js +++ /dev/null @@ -1,12 +0,0 @@ - -/*6 Create a function called vehicle, like before, - but takes another parameter called age, - so that vehicle("blue", 1, 5) prints 'a blue used car'*/ -function vehicle(color,code,age){ - if (code==1 && age<2){ - console.log("a " + color + " new car") - } - else if (code==1 && age>2) { - console.log("a " + color + " used car") - }} - vehicle("blue", 1, 5); From 8affdb4169e7be737172cbbc8413ded1c41360b7 Mon Sep 17 00:00:00 2001 From: Riam Alali <48811666+RiamAlali@users.noreply.github.com> Date: Wed, 15 May 2019 11:23:21 +0200 Subject: [PATCH 16/17] Delete More-JS-7-8-9-10-11.js --- Week3/More-JS-7-8-9-10-11.js | 51 ------------------------------------ 1 file changed, 51 deletions(-) delete mode 100644 Week3/More-JS-7-8-9-10-11.js diff --git a/Week3/More-JS-7-8-9-10-11.js b/Week3/More-JS-7-8-9-10-11.js deleted file mode 100644 index 852315f93..000000000 --- a/Week3/More-JS-7-8-9-10-11.js +++ /dev/null @@ -1,51 +0,0 @@ - -//7 Make a list of vehicles, you can add "motorbike", "caravan", "bike", or more. -let listOfVehicles = ["motorbike","caravan","bike"]; - -//8 How do you get the third element from that list? -console.log(listOfVehicles[2]); - - - - -/*9 Change the function vehicle to use the list of question 7. - So that vehicle("green", 3, 1) prints "a green new bike".*/ -function Vehicles(color,code,age){ -if(code=listOfVehicles[2] && age<2){ - console.log("a " + color + " new bike") -} -else { - console.log("a " + color + "old bike") -}; -} -Vehicles("green", 3, 1); - - -/*10 Use the list of vehicles to write an advertisement. -So that it prints something like: -"Amazing Joe's Garage, we service cars, motorbikes, caravans and bikes.". -(Hint: use a for loop.) -Hint, the output should be correct English with all the punctuation in place -(that's the challenge). So plurals for the vehicle types, commas followed by a single space, -the word and to replace the final comma and closed off by a period. */ - -//11 What if you add one more vehicle to the list, can you have that added to the advertisement without changing the code for question 10? - -listOfVehicles = ["motorbike","caravan","bike","car"]; - -function advertisement(listOfVehicles){ - for(let i=0; i Date: Wed, 15 May 2019 11:23:29 +0200 Subject: [PATCH 17/17] Delete strings-arrays.js --- Week3/strings-arrays.js | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 Week3/strings-arrays.js diff --git a/Week3/strings-arrays.js b/Week3/strings-arrays.js deleted file mode 100644 index 6a4d7400e..000000000 --- a/Week3/strings-arrays.js +++ /dev/null @@ -1,37 +0,0 @@ -//1.Strings -let myString = "hello,this,is,a,difficult,to,read,sentence"; -console.log(myString); -myString=myString.replace(/,/g, " "); // that's totally google answer i couldn't find what the g stands for -console.log(myString); - - - -//2 Arrays -let favoriteAnimals = ["blowfish", "capricorn", "giraffe"]; -// add Mauro's favorite animal 'turtle' -favoriteAnimals[3]="turtle"; -console.log(favoriteAnimals); - - - -//add Jim's favorite animal to the array, it's 'meerkat',to be placed after 'blowfish' and before 'capricorn'. -favoriteAnimals.splice(favoriteAnimals.length/ 3, 0, "meerkat"); -console.log("blowfish", "meerkat", "capricorn", "giraffe", "turtle"); -console.log(favoriteAnimals); - - - -// length of the array -console.log("The array has a length of: " + favoriteAnimals.length); - - - -// delete 'giraffe' from the array -favoriteAnimals.splice(3, 1); -console.log(favoriteAnimals); - - - - -// how to find the position or the index of the item 'meerkat' in the array? -console.log('The item you are looking for is at index: ' + favoriteAnimals.indexOf("meerkat"));