I get stuck in lesson 6 of introduction of function js...please send the code


#1



Replace this line with your code.


#2

Hi you should put your code so that we could help you...


#3

i get stuck in lesson 6 of introduction function of of js..help me out!


#4

var orangeCost=function (1$){
var val=1$*5;
console.log(val);
}
orangecost(5$)
what's the wrong?


#5

your function should take a argument which will be the cost of orange

var orangeCost = function(cost) {

}

I gave the function a argument cost which will be the cost of.....

then inside the function

var val=1$*5;
console.log(val);

you don't need of the symbol $ for the price it should be like that

var val= cost * 5;
console.log(val);

then you shoudl call the function orangeCost() just with the number 5 like that

orangeCost(5)

HOpe that could help you


#6

oh!!!! thank you soooooo much..:slight_smile:
:slight_smile:


#7

var timesTwo = function(number) {
return number * 2;
};

// Call timesTwo here!
var newNumber =timesTow(8);
console.log(newNumber);
what's the error?i t doesn't work out


#8

this part

var newNumber =timesTow(8);

you call the function timesTow() instead of timesTwo()


#9

HOW CAN I SOLVE THIS?? introduction to function js..lesson 12,,
var sleepCheck= function(numHours)
if (number of hours of sleep>8){
console.log("You're getting plenty of sleep!Maybe even too much!");
}
else{"Get some more shut eye!");
}
sleepCheck(10);
sleepCheck(5);
sleepCheck(8);


#10

HI this part

if (number of hours of sleep>8)

you should remove number of hours of sleep and put numHours.
then you should close your sleepCheck function.
like that

var sleepCheck = function() {#open the sleepCheck function

#Here put the if and else statement

}#close the sleepCheck function

here

console.log("You're getting plenty of sleep!Maybe even too much!");
else{"Get some more shut eye!");

you you should use return instead of console.log()


#11

what's the problem?it doesn't work...
var sleepCheck = function(numHours)
{
if (numHours >= 8)
{
return "You're getting plenty of sleep! Mabye even too much!";
}
else
{
return "Get some more shut eye!";
}
};
console.log(sleepCheck(10));
console.log(sleepCheck(5));
console.log(sleepCheck(8));


#12

what error do you get?


#13

Oops, try again. It looks like sleepCheck() isn't returning "You're getting plenty of sleep! Maybe even too much!" when numHours is 10. Check your if / else syntax and whether you're using the correct comparison operator.

that's the error...what should do next?


#14

I Really don't see the difference but try to copy that

return "You're getting plenty of sleep! Maybe even too much!";

#15

ok..thanks...if it work i will inform you.


#16

3 posts were split to a new topic: Quarter function doesn't return correct value


#17

2 posts were split to a new topic: Don't know what i am doing wrong


#18