Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on May 14, 2024. It is now read-only.

Conversation

@heartwhite
Copy link

@heartwhite heartwhite commented May 14, 2019

!!! 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

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
i just now understand challenge. I added a second console log using '?'
Copy link
Contributor

@marcianoviereck marcianoviereck left a 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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks.

Week3/moreJs-10.js Outdated Show resolved Hide resolved

function vehicle (color, type, age){
let types = [' car' , ' motorbike'];
console.log('a ' + color +' ' + condition(age) + types[(type-1)]);
Copy link
Contributor

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?

let types = [' car' , ' motorbike'];
console.log('a ' + color +' ' + condition(age) + types[(type-1)]);
}
function condition(years){
Copy link
Contributor

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

Copy link
Author

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

// and in case you can run in a html seperately.
console.log('a ' + color +' ' + condition(age) + vehicles[(type-1)]);
}
function condition(years){
Copy link
Contributor

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

Copy link
Author

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

*/

function vehicle (color, type, age){
let vehicles = ['motorbike' , 'caravan', 'bike', 'car'];
Copy link
Contributor

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?

Copy link
Author

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.
Copy link
Contributor

@marcianoviereck marcianoviereck left a 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 + '.');
}
Copy link
Contributor

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);
}

Copy link
Author

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

@NoerGitKat NoerGitKat closed this Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.