diff --git a/Week2/arraysTask-1.js b/Week2/arraysTask-1.js new file mode 100644 index 000000000..66334fcaa --- /dev/null +++ b/Week2/arraysTask-1.js @@ -0,0 +1,8 @@ +const str = 'dlroW olleH'; +console.log('my string is: '+str); +const splitString = str.split(''); +console.log('make it array: '+splitString); +const reverseArray = splitString.reverse(); +console.log('reverse array: '+reverseArray); +const joinArray = reverseArray.join(''); +console.log('corrected string is: '+joinArray); \ No newline at end of file diff --git a/Week2/homework/arraysTask-1.js b/Week2/homework/arraysTask-1.js new file mode 100644 index 000000000..66334fcaa --- /dev/null +++ b/Week2/homework/arraysTask-1.js @@ -0,0 +1,8 @@ +const str = 'dlroW olleH'; +console.log('my string is: '+str); +const splitString = str.split(''); +console.log('make it array: '+splitString); +const reverseArray = splitString.reverse(); +console.log('reverse array: '+reverseArray); +const joinArray = reverseArray.join(''); +console.log('corrected string is: '+joinArray); \ No newline at end of file diff --git a/Week2/homework/stringsTask-1.js b/Week2/homework/stringsTask-1.js new file mode 100644 index 000000000..ea23461a7 --- /dev/null +++ b/Week2/homework/stringsTask-1.js @@ -0,0 +1,4 @@ +const myString = "hello,this,is,a,difficult,to,read,sentence"; +console.log('my string is: '+myString); +console.log('length of the string is: '+myString.length+' characters'); +console.log('corrected string is: '+myString.replace(/,/g,' ')); diff --git a/Week2/homework/stringsTask-2.js b/Week2/homework/stringsTask-2.js new file mode 100644 index 000000000..66334fcaa --- /dev/null +++ b/Week2/homework/stringsTask-2.js @@ -0,0 +1,8 @@ +const str = 'dlroW olleH'; +console.log('my string is: '+str); +const splitString = str.split(''); +console.log('make it array: '+splitString); +const reverseArray = splitString.reverse(); +console.log('reverse array: '+reverseArray); +const joinArray = reverseArray.join(''); +console.log('corrected string is: '+joinArray); \ No newline at end of file diff --git a/Week2/homework/task01HelloWorld.js b/Week2/homework/task01HelloWorld.js new file mode 100644 index 000000000..d534e7e8f --- /dev/null +++ b/Week2/homework/task01HelloWorld.js @@ -0,0 +1,6 @@ +function helloWorld (greetings, language) { + console.log ( greetings + ' // ' + language) + }; + helloWorld ('Halo, dunia!', 'Indonesian'); + helloWorld ('Ciao, mondo!', 'Italian'); + \ No newline at end of file diff --git a/Week2/homework/task02SyntaxError.js b/Week2/homework/task02SyntaxError.js new file mode 100644 index 000000000..1be0ffb68 --- /dev/null +++ b/Week2/homework/task02SyntaxError.js @@ -0,0 +1 @@ +console.log("I'm awesome"); \ No newline at end of file diff --git a/Week2/homework/task03IntegerVariable.js b/Week2/homework/task03IntegerVariable.js new file mode 100644 index 000000000..8588fa54f --- /dev/null +++ b/Week2/homework/task03IntegerVariable.js @@ -0,0 +1,6 @@ +let x; +console.log("the value of my variable x will be: 13"); +console.log(x); +x=13; +console.log("the value of my variable x will be: 13"); +console.log(x); \ No newline at end of file diff --git a/Week2/homework/task04StringVariable.js b/Week2/homework/task04StringVariable.js new file mode 100644 index 000000000..d77b1d982 --- /dev/null +++ b/Week2/homework/task04StringVariable.js @@ -0,0 +1,6 @@ +let y = 'dog'; +console.log("the value of my variable x will be: cat"); +console.log(y); +y='cat'; +console.log("the value of my variable x will be: cat"); +console.log(y); \ No newline at end of file diff --git a/Week2/homework/task05RoundNumber.js b/Week2/homework/task05RoundNumber.js new file mode 100644 index 000000000..339a562fd --- /dev/null +++ b/Week2/homework/task05RoundNumber.js @@ -0,0 +1,10 @@ +let z = 7.25; +console.log(z); +let a = Math.round(z); +console.log(a); +if (z < a) { + fin = a; + } else { + fin = z; + }; +console.log(fin); \ No newline at end of file diff --git a/Week2/homework/task06FavoriteAnimalsArray.js b/Week2/homework/task06FavoriteAnimalsArray.js new file mode 100644 index 000000000..272ba87fc --- /dev/null +++ b/Week2/homework/task06FavoriteAnimalsArray.js @@ -0,0 +1,7 @@ +let animals = []; +console.log("the value of my array is: cat, dog, rabbit, bird"); +console.log(animals); +let myFavoriteAnimals = ['cat', 'dog', 'rabbit', 'bird']; +console.log(myFavoriteAnimals); +myFavoriteAnimals.push('baby pig'); +console.log(myFavoriteAnimals); \ No newline at end of file diff --git a/Week2/homework/task07StringLength.js b/Week2/homework/task07StringLength.js new file mode 100644 index 000000000..013e4fbac --- /dev/null +++ b/Week2/homework/task07StringLength.js @@ -0,0 +1,2 @@ +let myString = "this is a test"; +console.log(myString.length); \ No newline at end of file diff --git a/Week2/homework/task08VariablesTypes.js b/Week2/homework/task08VariablesTypes.js new file mode 100644 index 000000000..f8625a100 --- /dev/null +++ b/Week2/homework/task08VariablesTypes.js @@ -0,0 +1,33 @@ +x = 13; +y = 'cow'; +z = true; +c = 26; +console.log("The value of my variable x is: " + x); +console.log("The value of my variable x is: " + y); +console.log("The value of my variable x is: " + z); +console.log("The value of my variable x is: " + c); +console.log("I think the types of my variables are all different"); +console.log(typeof x); +console.log(typeof y); +console.log(typeof z); +console.log(typeof c); +if (typeof x===typeof y) { + console.log('SAME TYPE'); + } else { + console.log('different TYPEs'); + }; + if (typeof y===typeof z) { + console.log('SAME TYPE'); + } else { + console.log('different TYPEs'); + }; + if (typeof z===typeof c) { + console.log('SAME TYPE'); + } else { + console.log('different TYPEs'); + }; + if (typeof c===typeof x) { + console.log('SAME TYPE'); + } else { + console.log('different TYPEs'); + }; \ No newline at end of file diff --git a/Week2/homework/task09RemainerOfDividing.js b/Week2/homework/task09RemainerOfDividing.js new file mode 100644 index 000000000..8f54e72dd --- /dev/null +++ b/Week2/homework/task09RemainerOfDividing.js @@ -0,0 +1,7 @@ +x = 7; +x = x % 3; +console.log (x); +y = 6; +console.log ('remainer of 6 / 2 is ' + y % 2); +z = 14; +console.log ('remainer of 13 / 4 is ' + z % 4); \ No newline at end of file diff --git a/Week2/homework/task10ComparesingNumbers.js b/Week2/homework/task10ComparesingNumbers.js new file mode 100644 index 000000000..3b6ad0480 --- /dev/null +++ b/Week2/homework/task10ComparesingNumbers.js @@ -0,0 +1,6 @@ +let x = [13, 'cow', {}, [], true, null]; +console.log('You can store multiple types in array. For example, array "x" contains ' + x); +console.log('-Infinity equals +Infinity; This is'); +console.log(-Infinity===+Infinity); +console.log('6/0 equals 10/0; This is'); +console.log(6/0===10/0); diff --git a/Week2/stringsTask-1.js b/Week2/stringsTask-1.js new file mode 100644 index 000000000..ea23461a7 --- /dev/null +++ b/Week2/stringsTask-1.js @@ -0,0 +1,4 @@ +const myString = "hello,this,is,a,difficult,to,read,sentence"; +console.log('my string is: '+myString); +console.log('length of the string is: '+myString.length+' characters'); +console.log('corrected string is: '+myString.replace(/,/g,' ')); diff --git a/Week2/stringsTask-2.js b/Week2/stringsTask-2.js new file mode 100644 index 000000000..66334fcaa --- /dev/null +++ b/Week2/stringsTask-2.js @@ -0,0 +1,8 @@ +const str = 'dlroW olleH'; +console.log('my string is: '+str); +const splitString = str.split(''); +console.log('make it array: '+splitString); +const reverseArray = splitString.reverse(); +console.log('reverse array: '+reverseArray); +const joinArray = reverseArray.join(''); +console.log('corrected string is: '+joinArray); \ No newline at end of file diff --git a/Week2/task01HelloWorld.js b/Week2/task01HelloWorld.js new file mode 100644 index 000000000..d534e7e8f --- /dev/null +++ b/Week2/task01HelloWorld.js @@ -0,0 +1,6 @@ +function helloWorld (greetings, language) { + console.log ( greetings + ' // ' + language) + }; + helloWorld ('Halo, dunia!', 'Indonesian'); + helloWorld ('Ciao, mondo!', 'Italian'); + \ No newline at end of file diff --git a/Week2/task02SyntaxError.js b/Week2/task02SyntaxError.js new file mode 100644 index 000000000..1be0ffb68 --- /dev/null +++ b/Week2/task02SyntaxError.js @@ -0,0 +1 @@ +console.log("I'm awesome"); \ No newline at end of file diff --git a/Week2/task03IntegerVariable.js b/Week2/task03IntegerVariable.js new file mode 100644 index 000000000..8588fa54f --- /dev/null +++ b/Week2/task03IntegerVariable.js @@ -0,0 +1,6 @@ +let x; +console.log("the value of my variable x will be: 13"); +console.log(x); +x=13; +console.log("the value of my variable x will be: 13"); +console.log(x); \ No newline at end of file diff --git a/Week2/task04StringVariable.js b/Week2/task04StringVariable.js new file mode 100644 index 000000000..d77b1d982 --- /dev/null +++ b/Week2/task04StringVariable.js @@ -0,0 +1,6 @@ +let y = 'dog'; +console.log("the value of my variable x will be: cat"); +console.log(y); +y='cat'; +console.log("the value of my variable x will be: cat"); +console.log(y); \ No newline at end of file diff --git a/Week2/task05RoundNumber.js b/Week2/task05RoundNumber.js new file mode 100644 index 000000000..339a562fd --- /dev/null +++ b/Week2/task05RoundNumber.js @@ -0,0 +1,10 @@ +let z = 7.25; +console.log(z); +let a = Math.round(z); +console.log(a); +if (z < a) { + fin = a; + } else { + fin = z; + }; +console.log(fin); \ No newline at end of file diff --git a/Week2/task06FavoriteAnimalsArray.js b/Week2/task06FavoriteAnimalsArray.js new file mode 100644 index 000000000..272ba87fc --- /dev/null +++ b/Week2/task06FavoriteAnimalsArray.js @@ -0,0 +1,7 @@ +let animals = []; +console.log("the value of my array is: cat, dog, rabbit, bird"); +console.log(animals); +let myFavoriteAnimals = ['cat', 'dog', 'rabbit', 'bird']; +console.log(myFavoriteAnimals); +myFavoriteAnimals.push('baby pig'); +console.log(myFavoriteAnimals); \ No newline at end of file diff --git a/Week2/task07StringLength.js b/Week2/task07StringLength.js new file mode 100644 index 000000000..013e4fbac --- /dev/null +++ b/Week2/task07StringLength.js @@ -0,0 +1,2 @@ +let myString = "this is a test"; +console.log(myString.length); \ No newline at end of file diff --git a/Week2/task08VariablesTypes.js b/Week2/task08VariablesTypes.js new file mode 100644 index 000000000..f8625a100 --- /dev/null +++ b/Week2/task08VariablesTypes.js @@ -0,0 +1,33 @@ +x = 13; +y = 'cow'; +z = true; +c = 26; +console.log("The value of my variable x is: " + x); +console.log("The value of my variable x is: " + y); +console.log("The value of my variable x is: " + z); +console.log("The value of my variable x is: " + c); +console.log("I think the types of my variables are all different"); +console.log(typeof x); +console.log(typeof y); +console.log(typeof z); +console.log(typeof c); +if (typeof x===typeof y) { + console.log('SAME TYPE'); + } else { + console.log('different TYPEs'); + }; + if (typeof y===typeof z) { + console.log('SAME TYPE'); + } else { + console.log('different TYPEs'); + }; + if (typeof z===typeof c) { + console.log('SAME TYPE'); + } else { + console.log('different TYPEs'); + }; + if (typeof c===typeof x) { + console.log('SAME TYPE'); + } else { + console.log('different TYPEs'); + }; \ No newline at end of file diff --git a/Week2/task09RemainerOfDividing.js b/Week2/task09RemainerOfDividing.js new file mode 100644 index 000000000..8f54e72dd --- /dev/null +++ b/Week2/task09RemainerOfDividing.js @@ -0,0 +1,7 @@ +x = 7; +x = x % 3; +console.log (x); +y = 6; +console.log ('remainer of 6 / 2 is ' + y % 2); +z = 14; +console.log ('remainer of 13 / 4 is ' + z % 4); \ No newline at end of file diff --git a/Week2/task10ComparesingNumbers.js b/Week2/task10ComparesingNumbers.js new file mode 100644 index 000000000..3b6ad0480 --- /dev/null +++ b/Week2/task10ComparesingNumbers.js @@ -0,0 +1,6 @@ +let x = [13, 'cow', {}, [], true, null]; +console.log('You can store multiple types in array. For example, array "x" contains ' + x); +console.log('-Infinity equals +Infinity; This is'); +console.log(-Infinity===+Infinity); +console.log('6/0 equals 10/0; This is'); +console.log(6/0===10/0); diff --git a/Week3/task01ReplaceCharactersInStrings.js b/Week3/task01ReplaceCharactersInStrings.js new file mode 100644 index 000000000..ea23461a7 --- /dev/null +++ b/Week3/task01ReplaceCharactersInStrings.js @@ -0,0 +1,4 @@ +const myString = "hello,this,is,a,difficult,to,read,sentence"; +console.log('my string is: '+myString); +console.log('length of the string is: '+myString.length+' characters'); +console.log('corrected string is: '+myString.replace(/,/g,' ')); diff --git a/Week3/task01Strings.js b/Week3/task01Strings.js new file mode 100644 index 000000000..ea23461a7 --- /dev/null +++ b/Week3/task01Strings.js @@ -0,0 +1,4 @@ +const myString = "hello,this,is,a,difficult,to,read,sentence"; +console.log('my string is: '+myString); +console.log('length of the string is: '+myString.length+' characters'); +console.log('corrected string is: '+myString.replace(/,/g,' ')); diff --git a/Week3/task02AddDeleteElementsInArrays.js b/Week3/task02AddDeleteElementsInArrays.js new file mode 100644 index 000000000..4bb8ecc50 --- /dev/null +++ b/Week3/task02AddDeleteElementsInArrays.js @@ -0,0 +1,27 @@ +let favoriteAnimals = ["blowfish", "capricorn", "giraffe"]; +console.log('an array is: '+favoriteAnimals); +function mauroFavoriteAnimal() { + favoriteAnimals.splice([favoriteAnimals.length], 0, 'turtle'); + console.log('a new array is: '+favoriteAnimals); +}; +mauroFavoriteAnimal(); +function jimFavoriteAnimal() { + favoriteAnimals.splice(1, 0, 'meerkat'); + console.log('a new array is: '+favoriteAnimals); +}; +jimFavoriteAnimal(); +console.log("I think this line is very strange. I don't know why am I writing it :("); +console.log('The array has a length of: '+favoriteAnimals.length); +function deleteGiraffe() { + let giraffe = favoriteAnimals.indexOf("giraffe"); + favoriteAnimals.splice([giraffe], 1); + console.log('a new array is: '+favoriteAnimals); +}; +deleteGiraffe(); +function deleteMeerkat() { + let meerkat = favoriteAnimals.indexOf("meerkat"); + console.log('The item you are looking for is at index: '+meerkat); + favoriteAnimals.splice([meerkat], 1); + console.log('a new array is: '+favoriteAnimals); +}; +deleteMeerkat(); diff --git a/Week3/task02Arrays.js b/Week3/task02Arrays.js new file mode 100644 index 000000000..4bb8ecc50 --- /dev/null +++ b/Week3/task02Arrays.js @@ -0,0 +1,27 @@ +let favoriteAnimals = ["blowfish", "capricorn", "giraffe"]; +console.log('an array is: '+favoriteAnimals); +function mauroFavoriteAnimal() { + favoriteAnimals.splice([favoriteAnimals.length], 0, 'turtle'); + console.log('a new array is: '+favoriteAnimals); +}; +mauroFavoriteAnimal(); +function jimFavoriteAnimal() { + favoriteAnimals.splice(1, 0, 'meerkat'); + console.log('a new array is: '+favoriteAnimals); +}; +jimFavoriteAnimal(); +console.log("I think this line is very strange. I don't know why am I writing it :("); +console.log('The array has a length of: '+favoriteAnimals.length); +function deleteGiraffe() { + let giraffe = favoriteAnimals.indexOf("giraffe"); + favoriteAnimals.splice([giraffe], 1); + console.log('a new array is: '+favoriteAnimals); +}; +deleteGiraffe(); +function deleteMeerkat() { + let meerkat = favoriteAnimals.indexOf("meerkat"); + console.log('The item you are looking for is at index: '+meerkat); + favoriteAnimals.splice([meerkat], 1); + console.log('a new array is: '+favoriteAnimals); +}; +deleteMeerkat(); diff --git a/Week3/task03SumOfArguments.js b/Week3/task03SumOfArguments.js new file mode 100644 index 000000000..29ff0d3b6 --- /dev/null +++ b/Week3/task03SumOfArguments.js @@ -0,0 +1,7 @@ +let x; +function abcSum(a,b,c) { + x = a + b + c; + return x; +}; +abcSum(1,2,3); +console.log(x); \ No newline at end of file diff --git a/Week3/task04ColorCar.js b/Week3/task04ColorCar.js new file mode 100644 index 000000000..4390f805f --- /dev/null +++ b/Week3/task04ColorCar.js @@ -0,0 +1,4 @@ +function colorCar(color) { + console.log('a '+color+' car'); +}; +colorCar('red'); \ No newline at end of file diff --git a/Week3/task05ObjectProperties.js b/Week3/task05ObjectProperties.js new file mode 100644 index 000000000..d036f9e45 --- /dev/null +++ b/Week3/task05ObjectProperties.js @@ -0,0 +1,14 @@ +let person = { + firstname:"John", + lastname:"Doe", + age:50, + eyecolor:"blue" +}; +function showProVa() { + console.log('Parameters of an object is '+Object.getOwnPropertyNames(person)); + console.log('The actual values of the parameters is:'); + let x; + for (x in person) { + console.log(person[x]); +};}; +showProVa(); \ No newline at end of file diff --git a/Week3/task06VehicleBeginning.js b/Week3/task06VehicleBeginning.js new file mode 100644 index 000000000..4ce5c6495 --- /dev/null +++ b/Week3/task06VehicleBeginning.js @@ -0,0 +1,8 @@ +function vehicleType(color, code) { + if (code === 1) { + console.log('a '+color+' car'); + } else { + console.log('a '+color+' motorbike'); + }; +}; +vehicleType("blue",2); \ No newline at end of file diff --git a/Week3/task07SingleLine.js b/Week3/task07SingleLine.js new file mode 100644 index 000000000..296ecb3b4 --- /dev/null +++ b/Week3/task07SingleLine.js @@ -0,0 +1 @@ +console.log( 3 === 3 ? 'yes' : 'no'); \ No newline at end of file diff --git a/Week3/task08Vehicles.js b/Week3/task08Vehicles.js new file mode 100644 index 000000000..ca084d254 --- /dev/null +++ b/Week3/task08Vehicles.js @@ -0,0 +1,21 @@ +const vehicleCodes = ['plane', 'car', 'motorbike','caravan','bike']; + +function vehicle(color, code, age) { + const valueOfColor = color; + const valueOfCode = vehicleCodes[code]; + const valueOfAge = age <= 1 ? 'new' : 'used'; + console.log('a '+valueOfColor, valueOfAge, valueOfCode) +}; +vehicle("green", 3, 1); + +function advertisement() { + for (let i = 0; i < vehicleCodes.length; i += 1) { + vehicleCodes[i] = vehicleCodes[i] + "s"; + } + let strLast = vehicleCodes[vehicleCodes.length-1]; + let arr1 = vehicleCodes.slice(0, [vehicleCodes.length-1]); + let str1 = arr1.toString(); + let str2 = str1.replace(/,/g,', '); + console.log(`Amazing Joe's Garage, we service ${str2} and ${strLast}.`); +}; +advertisement(); \ No newline at end of file diff --git a/Week3/task09MakeObject.js b/Week3/task09MakeObject.js new file mode 100644 index 000000000..999e302a9 --- /dev/null +++ b/Week3/task09MakeObject.js @@ -0,0 +1,4 @@ +let Object = {}; +Object.teachers = ["Wilgert Velinga", "Bonan Zhao", "Yash Kapila"]; +Object.languages = ["Html / Css", "Git", "JavaScript"] +console.log(Object); \ No newline at end of file diff --git a/Week3/task10ComparingArrays.js b/Week3/task10ComparingArrays.js new file mode 100644 index 000000000..209586b62 --- /dev/null +++ b/Week3/task10ComparingArrays.js @@ -0,0 +1,9 @@ +let x = [1, 2, 3]; +let y = [1, 2, 3]; +let z = y; + +console.log(`What do you think will happen with x == y, x === y and z == y and z == x? +Well, I think x == y will be false; but it is ${x == y} +And, I think x === y will be false; but it is ${x === y} +And, I think z == y will be true; but it is ${z == y} +And, I think z == x will be false; but it is ${z == x}`); \ No newline at end of file diff --git a/Week3/task11SettingObjecktProperties.js b/Week3/task11SettingObjecktProperties.js new file mode 100644 index 000000000..8c2d030d9 --- /dev/null +++ b/Week3/task11SettingObjecktProperties.js @@ -0,0 +1,26 @@ +let o1 = { foo: "bar" }; +let o2 = { foo: "bar" }; +let o3 = o2; + +console.log(`o2 now has: ${Object.keys(o2)}`); + +o2.animal = `dog`; +console.log(`o2 was changed and o3 now has: ${Object.keys(o3)}`); + +o1.vehicle = `car`; +console.log(`o1 was changed and o3 now has: ${Object.keys(o3)}`); + +console.log(`now in the other order`); + +o1 = { foo: "bar" }; +o2 = { foo: "bar" }; +o3 = {}; +o2 = o3; + +console.log(`o3 is epmty object now so o2 now has: ${Object.keys(o2)}`); + +o2.animal = `dog`; +console.log(`o2 was changed and o3 now has: ${Object.keys(o3)}`); + +o1.vehicle = `car`; +console.log(`o1 was changed and o3 now has: ${Object.keys(o3)}`); \ No newline at end of file diff --git a/Week3/task12TypeOf.js b/Week3/task12TypeOf.js new file mode 100644 index 000000000..4c26029c3 --- /dev/null +++ b/Week3/task12TypeOf.js @@ -0,0 +1,5 @@ +let bar = 42; +console.log(`\`typeof bar\` console.log the type of the value of the variable \`bar\`, +which is ${typeof bar}, +and \`typeof typeof bar\` console.log the type of the return of the method of the object \`typeof\` +which is ${typeof typeof bar}`); \ No newline at end of file