diff --git a/Week2/week1/10_last-answer.js b/Week2/week1/10_last-answer.js new file mode 100644 index 000000000..c8b90875b --- /dev/null +++ b/Week2/week1/10_last-answer.js @@ -0,0 +1,13 @@ +let multiple = [ + 'string', + 23, + false +]; + +console.log('multiple types in an array : '+ multiple); + +console.log('\n'); + +console.log('6/0 = ' + 6/0); +console.log('10/0 = ' + 10/0); +console.log(6/0 === 10/0); \ No newline at end of file diff --git a/Week2/week1/1_helloworld.js b/Week2/week1/1_helloworld.js new file mode 100644 index 000000000..ee9c830fd --- /dev/null +++ b/Week2/week1/1_helloworld.js @@ -0,0 +1,6 @@ +console.log('Halo, dunia!'); //Indenosian +console.log('Ciao, mondo!'); //Italian +console.log('Hola, mundo!'); //Spanish +console.log('Merhaba, dunya!'); //Turkish +console.log('Hello, world'); //English +console.log('\n\n'); \ No newline at end of file diff --git a/Week2/week1/2_I'm awesome.js b/Week2/week1/2_I'm awesome.js new file mode 100644 index 000000000..c0ae072a7 --- /dev/null +++ b/Week2/week1/2_I'm awesome.js @@ -0,0 +1,3 @@ +console.log('I\'m awesome'); + +console.log('\n\n'); \ No newline at end of file diff --git a/Week2/week1/3_variable-x.js b/Week2/week1/3_variable-x.js new file mode 100644 index 000000000..5e6b61c3d --- /dev/null +++ b/Week2/week1/3_variable-x.js @@ -0,0 +1,13 @@ +let x; + +console.log('the value of my variable x will be: undefined'); + +console.log('value of x : ' + x); + +x = 3; + +console.log('the value of my variable x will be: 3'); + +console.log('value of x : ' + x); + +console.log('\n\n'); \ No newline at end of file diff --git a/Week2/week1/4_variable-y.js b/Week2/week1/4_variable-y.js new file mode 100644 index 000000000..35b2152ae --- /dev/null +++ b/Week2/week1/4_variable-y.js @@ -0,0 +1,13 @@ +let y = 'This is text.'; + +console.log('the value of my variable y will be: This is text.'); + +console.log('the value of y : ' + y); + +y = 'This is another text.'; + +console.log('the value of my variable y will be: This is another text.'); + +console.log('the value of y : ' + y); + +console.log('\n\n'); \ No newline at end of file diff --git a/Week2/week1/5_variable-z.js b/Week2/week1/5_variable-z.js new file mode 100644 index 000000000..15f07d6c8 --- /dev/null +++ b/Week2/week1/5_variable-z.js @@ -0,0 +1,22 @@ +let z = 7.25; + +console.log(z); + +let a = Math.round(z); + +console.log(a); + +let highest; + +if(a > z) +{ + highest = a; +} +else +{ + highest = z; +} + +console.log('highest is : ' + highest); + +console.log('\n\n'); \ No newline at end of file diff --git a/Week2/week1/6_arrays.js b/Week2/week1/6_arrays.js new file mode 100644 index 000000000..df46a64ce --- /dev/null +++ b/Week2/week1/6_arrays.js @@ -0,0 +1,20 @@ +let fancyAnimals = []; + +console.log('the values of my array fancyAnimals will be: '); + +console.log('values of fancyAnimals : ' + fancyAnimals); + +fancyAnimals = [ + 'cat', + 'dog', + 'bird', + 'fish' +]; + +console.log('values of fancyAnimals : ' + fancyAnimals); + +fancyAnimals.push('baby pig'); + +console.log('values of fancyAnimals : ' + fancyAnimals); + +console.log('\n\n'); \ No newline at end of file diff --git a/Week2/week1/7_strings.js b/Week2/week1/7_strings.js new file mode 100644 index 000000000..5845f4070 --- /dev/null +++ b/Week2/week1/7_strings.js @@ -0,0 +1,7 @@ +let myString = "this is a test"; + +console.log(myString); + +console.log('the length of myString : ' + myString.length); + +console.log('\n\n'); \ No newline at end of file diff --git a/Week2/week1/8_SAME-TYPE.js b/Week2/week1/8_SAME-TYPE.js new file mode 100644 index 000000000..15b573b98 --- /dev/null +++ b/Week2/week1/8_SAME-TYPE.js @@ -0,0 +1,65 @@ +let str1 = 'string1'; +let num1 = 13; +let bool = true; +let arr = ['cat', 'dog']; +let str2 = 'string2'; +let num2 = 14; + +console.log("The value of my variable str1 is: " + str1); +console.log("The value of my variable num1 is: " + num1); +console.log("The value of my variable bool is: " + bool); +console.log("The values of my variable arr is: " + arr); +console.log("The value of my variable str2 is: " + str2); +console.log("The value of my variable num2 is: " + num2); +console.log('\n'); + +console.log('the type of str1 will be: String'); +console.log('the type of num1 will be: Number'); +console.log('the type of bool will be: Boolean'); +console.log('the type of arr will be: Object'); +console.log('the type of str2 will be: String'); +console.log('the type of num2 will be: Number'); +console.log('\n'); + +console.log('the type of str1 is: ' + typeof(str1)); +console.log('the type of num1 is: ' + typeof(num1)); +console.log('the type of bool is: ' + typeof(bool)); +console.log('the type of arr is: ' + typeof(arr)); +console.log('the type of str2 is: ' + typeof(str2)); +console.log('the type of num2 is: ' + typeof(num2)); +console.log('\n'); + +let variables = []; +variables[0] = str1; +variables[1] = num1; +variables[2] = bool; +variables[3] = arr; +variables[4] = str2; +variables[5] = num2; + +let variableName = [ + 'str1', + 'num1', + 'bool', + 'arr', + 'str2', + 'num2' +]; + +for(let i = 0; i < (variables.length - 1); i++) +{ + for(let j = (i + 1); j < variables.length; j++) + { + if(typeof(variables[i]) == typeof(variables[j])) + { + console.log(variableName[i] + ' and ' + variableName[j] + ' are : SAME TYPE'); + } + else + { + console.log(variableName[i] + ' and ' + variableName[j] + ' are : NOT SAME TYPE'); + } + } + console.log('\n'); +} + +console.log('\n\n'); diff --git a/Week2/week1/9_modulo.js b/Week2/week1/9_modulo.js new file mode 100644 index 000000000..11f4c9318 --- /dev/null +++ b/Week2/week1/9_modulo.js @@ -0,0 +1,12 @@ +for(let x = 1; x < 8; x++) +{ + console.log('the value of x is : ' + x); + if(x == 7) + { + x = (x % 3); + console.log('When the value of x is : 7, the value of x changed to : ' + x); + break; + } +} + +console.log('\n\n'); \ No newline at end of file diff --git a/Week2/week1/index.html b/Week2/week1/index.html new file mode 100644 index 000000000..18bdec5cd --- /dev/null +++ b/Week2/week1/index.html @@ -0,0 +1,21 @@ + + + + + + Document + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Week3/week2/1-strings.js b/Week3/week2/1-strings.js new file mode 100644 index 000000000..811d5e521 --- /dev/null +++ b/Week3/week2/1-strings.js @@ -0,0 +1,8 @@ +let myString = "hello,this,is,a,difficult,to,read,sentence"; + +console.log(myString); +console.log(myString.length); +myString = myString.replace(/,/g , " "); +console.log(myString); + +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/2-arrays.js b/Week3/week2/2-arrays.js new file mode 100644 index 000000000..21905ebf9 --- /dev/null +++ b/Week3/week2/2-arrays.js @@ -0,0 +1,17 @@ +let favoriteAnimals = ["blowfish", "capricorn", "giraffe"]; + +favoriteAnimals.push("turtle"); +console.log(favoriteAnimals); + +favoriteAnimals.splice(1, 0, "meerkat"); +console.log("New value of favoriteAnimals will be : blowfish, meerkat, capricorn, giraffe, turtle"); +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")); + +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/index.html b/Week3/week2/index.html new file mode 100644 index 000000000..df3dd2253 --- /dev/null +++ b/Week3/week2/index.html @@ -0,0 +1,29 @@ + + + + + + Document + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-1.js b/Week3/week2/moreJavaScript-1.js new file mode 100644 index 000000000..1a2b11dc3 --- /dev/null +++ b/Week3/week2/moreJavaScript-1.js @@ -0,0 +1,10 @@ +function sum(arg1, arg2, arg3) { + if(isNaN(arg1) || isNaN(arg2) || isNaN(arg3)) { + return "least one of parameters is not a number!"; + } + return arg1 + arg2 + arg3; +} + +console.log(sum(1, 2, "afaf")); +console.log(sum(1, 2, 3)); +console.log("\n\n"); diff --git a/Week3/week2/moreJavaScript-10.js b/Week3/week2/moreJavaScript-10.js new file mode 100644 index 000000000..ab30d27a3 --- /dev/null +++ b/Week3/week2/moreJavaScript-10.js @@ -0,0 +1,10 @@ +function advertisement(vehicles) { + let text = "Amazing Joe's Garage, we service "; + for(let index = 0; index < (vehicles.length - 2); index++) { + text += (vehicles[index] + ", "); + } + console.log(text + vehicles[vehicles.length -2] + " and " + vehicles[vehicles.length -1] + "."); +} + +advertisement(vehicles); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-11.js b/Week3/week2/moreJavaScript-11.js new file mode 100644 index 000000000..9eb407eff --- /dev/null +++ b/Week3/week2/moreJavaScript-11.js @@ -0,0 +1,3 @@ +vehicles.push("truck"); +advertisement(vehicles); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-12.js b/Week3/week2/moreJavaScript-12.js new file mode 100644 index 000000000..1e7ca5a9e --- /dev/null +++ b/Week3/week2/moreJavaScript-12.js @@ -0,0 +1,4 @@ +let objc = {}; + +console.log(objc); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-13.js b/Week3/week2/moreJavaScript-13.js new file mode 100644 index 000000000..fb581a10f --- /dev/null +++ b/Week3/week2/moreJavaScript-13.js @@ -0,0 +1,7 @@ +let teachers = { + name : ["Philip", "Unmesh", "Sander"], + country : ["Germany", "India", "Netherland"] +} + +console.log(teachers); +console.log("\n\n"); diff --git a/Week3/week2/moreJavaScript-14.js b/Week3/week2/moreJavaScript-14.js new file mode 100644 index 000000000..cfe39d320 --- /dev/null +++ b/Week3/week2/moreJavaScript-14.js @@ -0,0 +1,4 @@ +teachers.languages = ["HTML-CSS", "GIT", "JAVASCRIPT"]; + +console.log(teachers); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-15.js b/Week3/week2/moreJavaScript-15.js new file mode 100644 index 000000000..ddaed780c --- /dev/null +++ b/Week3/week2/moreJavaScript-15.js @@ -0,0 +1,9 @@ +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); +console.log(z == x); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-16.js b/Week3/week2/moreJavaScript-16.js new file mode 100644 index 000000000..47dd40d3c --- /dev/null +++ b/Week3/week2/moreJavaScript-16.js @@ -0,0 +1,30 @@ +let o1 = { foo: "bar" }; +let o2 = { foo: "bar" }; +let o3 = o2; + +console.log(o1); +console.log(o2); +console.log(o3); +console.log("\n"); + +console.log(o3); +o2.foo = "bar2"; +console.log(o3); // Yes it changes +console.log("\n"); + +console.log(o3); +o1.foo = "barX"; +console.log(o3); // No it doesn't change +console.log("\n"); + +console.log(o1); +console.log(o2); +console.log(o3); +console.log("\n"); + +o2 = o3; + +console.log(o1); +console.log(o2); +console.log(o3); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-17.js b/Week3/week2/moreJavaScript-17.js new file mode 100644 index 000000000..e0bcf0ef7 --- /dev/null +++ b/Week3/week2/moreJavaScript-17.js @@ -0,0 +1,5 @@ +let bar = 42; + +let result = typeof bar; +result = typeof result; // result = typeof typeof bar; +console.log(result); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-2.js b/Week3/week2/moreJavaScript-2.js new file mode 100644 index 000000000..c51babe11 --- /dev/null +++ b/Week3/week2/moreJavaScript-2.js @@ -0,0 +1,11 @@ +function colorCar(color) { + if(typeof(color) !== "string") { + console.log(color + " is not a string!"); + } else { + console.log("a " + color +" car"); + } +} + +colorCar(2); +colorCar("red"); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-3.js b/Week3/week2/moreJavaScript-3.js new file mode 100644 index 000000000..16b57a2f3 --- /dev/null +++ b/Week3/week2/moreJavaScript-3.js @@ -0,0 +1,15 @@ +const user = { + name : "Pete", + surname : "Smith", + age : 27, + 'doingSport' : true, +}; + +function printOut(obj) { + for(prop in obj) { + console.log(prop + " : " + obj[prop]); + } +} + +printOut(user); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-4.js b/Week3/week2/moreJavaScript-4.js new file mode 100644 index 000000000..59383949c --- /dev/null +++ b/Week3/week2/moreJavaScript-4.js @@ -0,0 +1,24 @@ +function vehicleType(color, code) { + if(typeof(color) !== "string" || typeof(code) !== "number") { + console.log("the least one of two parameters is invalid!"); + } else { + switch(code) { + case 1: + console.log("a " + color + " car"); + break; + case 2: + console.log("a " + color + " motorbike"); + break; + default: + console.log("invalid code!"); + break; + } + } +} + +vehicleType(true, 2); +vehicleType(1, "black"); +vehicleType("white", 3); +vehicleType("red", 1); +vehicleType("blue", 2); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-5.js b/Week3/week2/moreJavaScript-5.js new file mode 100644 index 000000000..fd04255c2 --- /dev/null +++ b/Week3/week2/moreJavaScript-5.js @@ -0,0 +1,2 @@ +console.log((3 === 3) ? "yes" : "no"); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-6.js b/Week3/week2/moreJavaScript-6.js new file mode 100644 index 000000000..f5dff1cbc --- /dev/null +++ b/Week3/week2/moreJavaScript-6.js @@ -0,0 +1,21 @@ +function vehicle(color, code, age) { + if( (typeof(color) !== "string") || (typeof(code) !== "number") || (typeof(age) !== "number") || (age < 0)) { + console.log("the least one of three parameters is invalid!"); + } else { + switch(code) { + case 1: + console.log("a " + color + " used car"); + break; + case 2: + console.log("a " + color + " used motorbike"); + break; + default: + console.log("invalid code!"); + break; + } + } +} + +vehicle("yellow", 2, -3); +vehicle("blue", 1, 5); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-7.js b/Week3/week2/moreJavaScript-7.js new file mode 100644 index 000000000..f1beb1d4d --- /dev/null +++ b/Week3/week2/moreJavaScript-7.js @@ -0,0 +1,10 @@ +let vehicles = [ + "motorbike", + "caravan", + "bike", + "car", + "bus" +]; + +console.log(vehicles); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-8.js b/Week3/week2/moreJavaScript-8.js new file mode 100644 index 000000000..c422ebf31 --- /dev/null +++ b/Week3/week2/moreJavaScript-8.js @@ -0,0 +1,2 @@ +console.log(vehicles[2]); +console.log("\n\n"); \ No newline at end of file diff --git a/Week3/week2/moreJavaScript-9.js b/Week3/week2/moreJavaScript-9.js new file mode 100644 index 000000000..73446caa8 --- /dev/null +++ b/Week3/week2/moreJavaScript-9.js @@ -0,0 +1,31 @@ +function vehicleNew(color, code, age) { + let ageType = (age === 1) ? " new " : " used "; + if( (typeof(color) !== "string") || (typeof(code) !== "number") || (typeof(age) !== "number") || (age < 0)) { + console.log("the least one of three parameters is invalid!"); + } else { + switch(code) { + case 1: + console.log("a " + color + ageType + vehicles[0]); + break; + case 2: + console.log("a " + color + ageType + vehicles[1]); + break; + case 3: + console.log("a " + color + ageType + vehicles[2]); + break; + case 4: + console.log("a " + color + ageType + vehicles[3]); + break; + case 5: + console.log("a " + color + ageType + vehicles[4]); + break; + default: + console.log("invalid code!"); + break; + } + } +} + +vehicleNew("green", 3, 1); +vehicleNew("white", 2, 2); +console.log("\n\n"); \ No newline at end of file