-
Notifications
You must be signed in to change notification settings - Fork 255
homework from Ann-Grabetski #155
Changes from all commits
5d9d7df
5b61855
a44a4f2
5a57336
9522342
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wondering why did you have to repeat this homework submission here? I remember that you were unable to make it to the Week1 where we covered Gitflow in a bit more detail. Let me or Tjebbe know please if you have any confusions or questions around working with Git and we can perhaps work on something. 🙂
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I did it accidentally then I figured out how to correctly use all this git system. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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,' ')); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 for logic. I would also like to introduce a new feature in JavaScript ES6 called template literals. It can be found here - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals Using template literals allows you to combine variables and strings and avoid using
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I already start to use them. And I love it! |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This again? 🤔 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| function helloWorld (greetings, language) { | ||
| console.log ( greetings + ' // ' + language) | ||
| }; | ||
| helloWorld ('Halo, dunia!', 'Indonesian'); | ||
| helloWorld ('Ciao, mondo!', 'Italian'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very nice of you to create a function for this purpose. 👏 However, there is a slight indentation problem on line 3. 🙂
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra tab? |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| console.log("I'm awesome"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| let x; | ||
| console.log("the value of my variable x will be: 13"); | ||
| console.log(x); | ||
| x=13; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A very small thing to improve is space between words like -
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got it. |
||
| console.log("the value of my variable x will be: 13"); | ||
| console.log(x); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| let y = 'dog'; | ||
| console.log("the value of my variable x will be: cat"); | ||
| console.log(y); | ||
| y='cat'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above about spacing 🙂
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep |
||
| console.log("the value of my variable x will be: cat"); | ||
| console.log(y); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A couple things to improve here:
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| let animals = []; | ||
| console.log("the value of my array is: cat, dog, rabbit, bird"); | ||
| console.log(animals); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Err!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought it's a part of the task. |
||
| let myFavoriteAnimals = ['cat', 'dog', 'rabbit', 'bird']; | ||
| console.log(myFavoriteAnimals); | ||
| myFavoriteAnimals.push('baby pig'); | ||
| console.log(myFavoriteAnimals); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| let myString = "this is a test"; | ||
| console.log(myString.length); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two things here:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| console.log(typeof x); | ||
| console.log(typeof y); | ||
| console.log(typeof z); | ||
| console.log(typeof c); | ||
| if (typeof x===typeof y) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm.. I wonder why there is indentation problem when you are using Also, make sure you include spaces which makes code more readable. Something like:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| 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'); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only missing thing here is using |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| let x = [13, 'cow', {}, [], true, null]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just FYI - if you are not going to reassign a variable later in the code(
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got it. Thanks. |
||
| 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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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,' ')); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| function helloWorld (greetings, language) { | ||
| console.log ( greetings + ' // ' + language) | ||
| }; | ||
| helloWorld ('Halo, dunia!', 'Indonesian'); | ||
| helloWorld ('Ciao, mondo!', 'Italian'); | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| console.log("I'm awesome"); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| let myString = "this is a test"; | ||
| console.log(myString.length); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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'); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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,' ')); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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,' ')); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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(); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| let favoriteAnimals = ["blowfish", "capricorn", "giraffe"]; | ||
| console.log('an array is: '+favoriteAnimals); | ||
| function mauroFavoriteAnimal() { | ||
| favoriteAnimals.splice([favoriteAnimals.length], 0, 'turtle'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also use
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| console.log('a new array is: '+favoriteAnimals); | ||
| }; | ||
| mauroFavoriteAnimal(); | ||
| function jimFavoriteAnimal() { | ||
| favoriteAnimals.splice(1, 0, 'meerkat'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| 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"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also use
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| 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(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| let x; | ||
| function abcSum(a,b,c) { | ||
| x = a + b + c; | ||
| return x; | ||
| }; | ||
| abcSum(1,2,3); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aahaan. This isn't the best way of dealing this situation. When we write functions in JavaScript, we should try to use only function parameters or local function variables instead of relying on variables outside the function's scope. Thus, using
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now I understand. Thank you. |
||
| console.log(x); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| function colorCar(color) { | ||
| console.log('a '+color+' car'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| }; | ||
| colorCar('red'); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| let person = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| 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]); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm.. I think a better way to do this would be like this: What do you think? Can you see some advantages of writing a function like this?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, I think I wrote pretty the same function. The only difference is that my function shows not only values but names of properties also. As it was asked in a task. |
||
| };}; | ||
| showProVa(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| console.log( 3 === 3 ? 'yes' : 'no'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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'; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of conditional operator here 👍 |
||
| 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(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| let Object = {}; | ||
| Object.teachers = ["Wilgert Velinga", "Bonan Zhao", "Yash Kapila"]; | ||
| Object.languages = ["Html / Css", "Git", "JavaScript"] | ||
| console.log(Object); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very well. The logic is correct but you can also reduce it in a single statement using a programming practice called method chaining. For example,
Here I have merged all three operations in a single statement using method chaining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! It's a very great way! Thank you to show me.