From 0ec00d8eedbacf335dfc7170402f10c2dbb9d072 Mon Sep 17 00:00:00 2001 From: Abdullah Date: Thu, 9 May 2019 16:36:58 +0200 Subject: [PATCH 1/3] Abdullah Al Ahmad JavaScript homework - week1 --- Week1/index.html | 12 +++ Week1/js1-w1-A.A.A.js | 175 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 Week1/index.html create mode 100644 Week1/js1-w1-A.A.A.js diff --git a/Week1/index.html b/Week1/index.html new file mode 100644 index 000000000..3caec7b6d --- /dev/null +++ b/Week1/index.html @@ -0,0 +1,12 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git a/Week1/js1-w1-A.A.A.js b/Week1/js1-w1-A.A.A.js new file mode 100644 index 000000000..2b6101935 --- /dev/null +++ b/Week1/js1-w1-A.A.A.js @@ -0,0 +1,175 @@ +// Greetings + +console.log ('Hello World!'); //English + +console.log ('Halo, Dunia!'); // Indonesian + +console.log ('Ciao Mondo!'); // Italian + +console.log ('Hola Mundo!'); // Spanish + + +// Debug single quote issue + +console.log('I\'m awesome'); + +// Variables & Values + +var x; + +console.log("the value of my variable x will be: a number"); + +console.log(x); + +x = 12; + +console.log("the value of my variable x will be: a number"); + +console.log(x); + +var y = 'Tom'; + +console.log("the value of my atring y will be: a name"); + +console.log(y); + +var y = y + '&Jerry'; + +console.log("the value of my string y will be: a cartoon name"); + +console.log(y); + +var z = 7.25; + +console.log(z); + +// Round z to the closest integer + +var round = Math.round; + +var a = round(z); + +console.log(a); + +// Print higher value z or a + +if (a Date: Thu, 16 May 2019 00:25:05 +0200 Subject: [PATCH 2/3] JS-week2 corrections done --- Week1/index.html | 12 --- Week1/js1-w1-A.A.A.js | 175 ---------------------------------------- Week2/%.js | 8 ++ Week2/arrays.js | 15 ++++ Week2/dataType.js | 61 ++++++++++++++ Week2/helloWorld.js | 11 +++ Week2/imAwesome.js | 17 ++++ Week2/index.html | 30 +++++++ Week2/moreStrings.js | 7 ++ Week2/multiDataTypes.js | 16 ++++ Week2/roundNumber.js | 24 ++++++ Week2/tom&jerry.js | 11 +++ 12 files changed, 200 insertions(+), 187 deletions(-) delete mode 100644 Week1/index.html delete mode 100644 Week1/js1-w1-A.A.A.js create mode 100644 Week2/%.js create mode 100644 Week2/arrays.js create mode 100644 Week2/dataType.js create mode 100644 Week2/helloWorld.js create mode 100644 Week2/imAwesome.js create mode 100644 Week2/index.html create mode 100644 Week2/moreStrings.js create mode 100644 Week2/multiDataTypes.js create mode 100644 Week2/roundNumber.js create mode 100644 Week2/tom&jerry.js diff --git a/Week1/index.html b/Week1/index.html deleted file mode 100644 index 3caec7b6d..000000000 --- a/Week1/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - Document - - - - - \ No newline at end of file diff --git a/Week1/js1-w1-A.A.A.js b/Week1/js1-w1-A.A.A.js deleted file mode 100644 index 2b6101935..000000000 --- a/Week1/js1-w1-A.A.A.js +++ /dev/null @@ -1,175 +0,0 @@ -// Greetings - -console.log ('Hello World!'); //English - -console.log ('Halo, Dunia!'); // Indonesian - -console.log ('Ciao Mondo!'); // Italian - -console.log ('Hola Mundo!'); // Spanish - - -// Debug single quote issue - -console.log('I\'m awesome'); - -// Variables & Values - -var x; - -console.log("the value of my variable x will be: a number"); - -console.log(x); - -x = 12; - -console.log("the value of my variable x will be: a number"); - -console.log(x); - -var y = 'Tom'; - -console.log("the value of my atring y will be: a name"); - -console.log(y); - -var y = y + '&Jerry'; - -console.log("the value of my string y will be: a cartoon name"); - -console.log(y); - -var z = 7.25; - -console.log(z); - -// Round z to the closest integer - -var round = Math.round; - -var a = round(z); - -console.log(a); - -// Print higher value z or a - -if (a + + + + + + JS-week1 + + +

JS-week2

+ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Week2/moreStrings.js b/Week2/moreStrings.js new file mode 100644 index 000000000..5314697f0 --- /dev/null +++ b/Week2/moreStrings.js @@ -0,0 +1,7 @@ +// String Length + +let myString = "this is a test"; + +console.log(myString); + +console.log(myString.length); \ No newline at end of file diff --git a/Week2/multiDataTypes.js b/Week2/multiDataTypes.js new file mode 100644 index 000000000..76734c776 --- /dev/null +++ b/Week2/multiDataTypes.js @@ -0,0 +1,16 @@ +// Array with multiple data types + +console.log('following array contains 2 numbers, 2 strings and a boolean'); + +let multipleTypesArray = [0, 'hero', 2, 'too', false]; + +console.log(multipleTypesArray); + +// Comparing infinities + +if (10/0 === 6/0) { + console.log('Yes! they\'re equal!'); + +} else { + console.log('There\'s no equality in this!'); +} \ No newline at end of file diff --git a/Week2/roundNumber.js b/Week2/roundNumber.js new file mode 100644 index 000000000..0679cdb01 --- /dev/null +++ b/Week2/roundNumber.js @@ -0,0 +1,24 @@ + +let z = 7.25; + +console.log(z); + +// Round z to the closest integer + +let round = Math.round; + +let a = round(z); + +console.log(a); + +// Print higher value z or a + +if (a Date: Sat, 18 May 2019 00:00:24 +0200 Subject: [PATCH 3/3] Abdullah Al Ahmad- js1 - week3 --- Week2/index.html | 2 +- Week3/advertisement.js | 26 ++++++++++++++++++++++++++ Week3/arrays.js | 23 +++++++++++++++++++++++ Week3/colorFun.js | 7 +++++++ Week3/index.html | 34 ++++++++++++++++++++++++++++++++++ Week3/strings.js | 6 ++++++ Week3/sumFun.js | 13 +++++++++++++ Week3/vehicle.js | 18 ++++++++++++++++++ Week3/vehicleList.js | 28 ++++++++++++++++++++++++++++ Week3/vehicleType.js | 13 +++++++++++++ 10 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 Week3/advertisement.js create mode 100644 Week3/arrays.js create mode 100644 Week3/colorFun.js create mode 100644 Week3/index.html create mode 100644 Week3/strings.js create mode 100644 Week3/sumFun.js create mode 100644 Week3/vehicle.js create mode 100644 Week3/vehicleList.js create mode 100644 Week3/vehicleType.js diff --git a/Week2/index.html b/Week2/index.html index c9cc7ae78..567877d9f 100644 --- a/Week2/index.html +++ b/Week2/index.html @@ -4,7 +4,7 @@ - JS-week1 + JS-week2

JS-week2

diff --git a/Week3/advertisement.js b/Week3/advertisement.js new file mode 100644 index 000000000..2a21ce14b --- /dev/null +++ b/Week3/advertisement.js @@ -0,0 +1,26 @@ +// 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. + + +let ad = "Amazing Joe's Garage, we service "; +function advertisement (){ + for( i = 0 ; i < vehicles.length; i++){ + + if (i == vehicles.length-1){ + ad += 's' + ' and ' + vehicles[i] + 's' + '.'; + }else if(i == vehicles.length-2){ + ad += vehicles[i]; + } + else { ad += vehicles[i]+ 's' + ', ' ; + } +}console.log(ad) +} + +// adding one vehicles to the list + +vehicles.push('scooter'); + +advertisement(); + + diff --git a/Week3/arrays.js b/Week3/arrays.js new file mode 100644 index 000000000..50b925101 --- /dev/null +++ b/Week3/arrays.js @@ -0,0 +1,23 @@ +let favoriteAnimals = ["blowfish", "capricorn", "giraffe"]; + +favoriteAnimals.push('turtle'); + +console.log(favoriteAnimals); + +favoriteAnimals.splice(1,0,'meerkat'); + +console.log('the value of the array will be 5 strings') + +console.log(favoriteAnimals); + +console.log('The array has a length of: ', favoriteAnimals.length) + +favoriteAnimals.splice(3,1); + +console.log(favoriteAnimals); + +console.log('The item you are looking for is at index: ', favoriteAnimals.indexOf('meerkat')); + + + + diff --git a/Week3/colorFun.js b/Week3/colorFun.js new file mode 100644 index 000000000..4ed5b9380 --- /dev/null +++ b/Week3/colorFun.js @@ -0,0 +1,7 @@ +// Create a function named colorCar that receives a color, and prints out, 'a red car' for example. + +function colorCar(color){ + console.log('a ' + color + ' car'); + } + +colorCar('red'); \ No newline at end of file diff --git a/Week3/index.html b/Week3/index.html new file mode 100644 index 000000000..dc18c805f --- /dev/null +++ b/Week3/index.html @@ -0,0 +1,34 @@ + + + + + + + JS-week3 + + + +

JS-week3

+ + ` + + + + + + + + + + + + + \ No newline at end of file diff --git a/Week3/strings.js b/Week3/strings.js new file mode 100644 index 000000000..16c2e1c46 --- /dev/null +++ b/Week3/strings.js @@ -0,0 +1,6 @@ +let myString = "hello,this,is,a,difficult,to,read,sentence"; + +console.log(myString.length); + +console.log(myString.replace(/,/g," ")); + diff --git a/Week3/sumFun.js b/Week3/sumFun.js new file mode 100644 index 000000000..21ddb800f --- /dev/null +++ b/Week3/sumFun.js @@ -0,0 +1,13 @@ +// Create a function that takes 3 arguments and returns the sum of the these arguments. + +function sum(){ + let sum =0; + for(let i=0;i