Skip to content

week 7 homework#13

Open
esyasar wants to merge 1 commit into
hackyourfuturecanada:Elif-Sude-Yasarfrom
esyasar:master
Open

week 7 homework#13
esyasar wants to merge 1 commit into
hackyourfuturecanada:Elif-Sude-Yasarfrom
esyasar:master

Conversation

@esyasar
Copy link
Copy Markdown

@esyasar esyasar commented Sep 4, 2019

I apologize for late homework. I needed to do some subject repeat for answers to get everything clear.

Copy link
Copy Markdown
Collaborator

@epq epq left a comment

Choose a reason for hiding this comment

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

Overall, you did a great job. If there are concepts you would still like to review, please ask!

Comment thread answer.js
var p1 = 6;
var p2 = 7;
var p3 = 10;
function tripleFunction (p1,p2,p3) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good work!

Comment thread answer.js
// 2.answer

function colorCar(color){
console.log( 'a' +''+ color +''+ 'car');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is good but the output doesn't have spaces. If you want to put spaces, you need to use a space in your string ' ' instead of ''.

Comment thread answer.js
if (code === 1){
console.log('a'+ color + 'car')
}
else {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Motorbike should only print out if the code is 2. What will this function print out if you call it with values other than 1 or 2?

Comment thread answer.js
function vehicle(color,age,code){

if (age <= 1){
console.log('a'+ color + 'new' + code);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

make sure your output has spaces so it's easily readable! You can add spaces like this:

console.log('a '+ color + ' new ' + code);

Comment thread answer.js
if (age <= 1){
console.log('a'+ color + 'new' + code);
}else if(age >1){
console.log('a'+''+ color +''+ 'used' +''+ code);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same comment as above regarding spaces. You should use ' ' to add a space instead of ''.

Comment thread answer.js
//6.answer

let code = ["car" , "motorbike"]
function vehicle(color,age,code){
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think you combined questions 6 and 9 but that's okay!
Question 9 involves writing a function with three parameters, color, age, and code. code should be a number (array index) that you use to get the value from an array. It shouldn't be the actual element from the array.
For example, you are calling your function like this:

vehicle("blue", 3 , code[0]); // the third parameter, code[0], is the string "car" from your array on line 57

The function should be called like this:

vehicle("blue", 3, 0); // the third parameter is a number (array index)

Then in the function, you should use the array index to get the vehicle type from the array.

Comment thread ex.js
// TODO: define printFavoriteBooks() function

function printFavoriteBooks(){
console.log('There are' + favoriteBooks.length + 'favorite books.');
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Well done! Just make sure to add spaces in your output. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants