-
Notifications
You must be signed in to change notification settings - Fork 255
Abdullah week3 JS homework #120
Conversation
Javascript week1homework
abdullah github-username:heartwhite
up to Marcianos feedback. I used .push for adding
compared all variables at all angles
I took infinitives into Variables , than compared to make it more readable .
console.log for each language
changed calculating to Math.max to find highest.
.push chanced to myFavoriteAnimals variable
index.html and 19 js files for steps of homework
Heartwhite patch 1
i just now understand challenge. I added a second console log using '?'
marcianoviereck
left a comment
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.
Overall the homework looks good! But there are just some remarks here and there, if you can fix those then the homework is approved!:)
| let a = Math.round(z); | ||
| console.log(a); | ||
| let numbers = [a, z]; | ||
| let highNumber=(Math.max(z,a)); |
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.
nice!
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.
thanks.
Week3/moreJs-6.js
Outdated
|
|
||
| function vehicle (color, type, age){ | ||
| let types = [' car' , ' motorbike']; | ||
| console.log('a ' + color +' ' + condition(age) + types[(type-1)]); |
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.
What happens if you pass '3' as value for the type as arguments? Will this still work?
Week3/moreJs-6.js
Outdated
| let types = [' car' , ' motorbike']; | ||
| console.log('a ' + color +' ' + condition(age) + types[(type-1)]); | ||
| } | ||
| function condition(years){ |
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.
Maybe the name age here is more consistent, because you use it aswell above
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.
yes. you re right.
I was trying to find some other parameters name. I thought it might confuse ('age' in 2 places).
but I forgot about scopes, and parameters I think.
I changed it to age. its better
Week3/moreJs-9.js
Outdated
| // and in case you can run in a html seperately. | ||
| console.log('a ' + color +' ' + condition(age) + vehicles[(type-1)]); | ||
| } | ||
| function condition(years){ |
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.
Maybe the name age here is more consistent, because you use it aswell above
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.
yes. you re right.
I was trying to find some other parameters name. I thought it might confuse ('age' in 2 places).
but I forgot about scopes, and parameters I think.
I changed it to age. its better
Week3/moreJs-9.js
Outdated
| */ | ||
|
|
||
| function vehicle (color, type, age){ | ||
| let vehicles = ['motorbike' , 'caravan', 'bike', 'car']; |
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.
What happens if you pass '10' as value for the type as arguments? Will this still work?
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.
it returns like ' undefined ' .
I added an if statement that logs a warning when the value is out of range ( length of array).
1 - condition's (function) parameter changed as 'age' from 'years'. this way more consistent with lines above. 2- if statement added for the value of 'type' parameter. console logs the vehicle only if it has vehicle type. otherwise logs an warning
1 - condition's (function) parameter changed as 'age' from 'years'. this way more consistent with lines above. 2- if statement added for the value of 'type' parameter. console logs the vehicle only if it has vehicle type. otherwise logs an warning
removed unnecessary ',' from end of line 19.
marcianoviereck
left a comment
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.
Nice! The homework is approved.
| products.splice(products.length - 2, 2); | ||
|
|
||
| console.log("Amazing Abdullah's Garage, we sell " + products.join() + ',' + lastTwoProduct + '.'); | ||
| } |
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.
This is fine!
Another way to do this is this:
vehicles = ["car", "bike", "train"];
function advertisement() {
let fullString = "Amazing Joe's Garage, we service ";
for (let i = 0; i < vehicles.length; i++) {
const element = vehicles[i];
if (i < vehicles.length - 2) {
fullString += vehicles[i] + ', ';
} else if (i === vehicles.length - 2) {
fullString += vehicles[i];
} else {
fullString += ' and ' + vehicles[vehicles.length - 1] + "."
}
}
console.log(fullString);
}
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.
I think your example automate better. Thanks. it will be in my codes today before evening
!!! important..!!
here there are some changes from old weeks . please look after "Week3/arrays.js"
12 changes on head are old. (because I did my changes on pull requests page according to Marcianos feedback. afterwards I applied changes on my page on forked repo. that's why the files seem changed ... I'm sorry for the mess...
JUST klick "WEEK3" (the link one before the last link) for HOMEWORK