Codecademy: Javascript Lessons- 8- Functions and Variables

preview_player
Показать описание
Codecademy: Javascript Lessons- 8- Functions and Variables
Learning how to write functions and variables with Codecademy.

Scopes in javascript
-----------------------------------------------------------------
Java Tutorials Coming Soon.
Follow me on Twitter- Henry1502inc and thecodeacademy
-----------------------------------------------------------------
New videos every Monday, Thursdays and Saturdays- 3pm to 8pm.
Рекомендации по теме
Комментарии
Автор

Scope is basically letting you know that variables that are assigned in a function are only available to that function and not available to other parts of your code. So defining it outside of the function allows you to use it in other parts of your coding, therefore making it global.

joediviak
Автор

that has happened to me a few times also

TheCodeAcademy
Автор

THANKS!!! I love this program and I will always do so! SUB FOR U!

cassidyarmani
Автор

After reviewing the code, I honestly have no idea what I was thinking using the module operator at all in the code. As Nicolas, John and many more stated below, you will get an error free program if you do two things, REMOVE THE MODULE 3, and use return instead of console dot log

Sorry about the mistake

TheCodeAcademy
Автор

yeah that's what I am saying, Codecademy pls answer on dis one..!

dhavaldabhi
Автор

this is the answer for question #8 Functions, return and if / else
hope it will help you guys

var quarter = function (number) {
    return number / 4;
};
if (quarter(12) % 3 === 0 ) {
  console.log("The statement is true");
} else {
  console.log("The statement is false");
}
quarter(12);

CyrusStudio
Автор

use return ("You earn a lot of money! You qualify for a credit card.")

instead of

console.log ("You earn a lot of money! You qualify for a credit card.")

RoweMods
Автор

You do perfect. But when we're making the question about creditCheck, we've got to do it through the "return" but not using "console.log". Right?

alfanjes
Автор

gahahaha thanks alot this helped alot and better to understand now :)

padde
Автор

var creditCheck = function (income){
if (income >= 100){
return "You earn a lot of money! You qualify for a credit card.";
}else{
return "Alas you do not qualify for a credit card. Capitalism is cruel like that.";
}
};
console.log(creditCheck(75));


This worked for me!

dkliem
Автор

what did you do and what doesn't work?

TheCodeAcademy
Автор

Correct answer:
var nameString = function (name) {
return "Hi, I am" + " " + name;

};

erandall
Автор

So I was stuck at this for about 15 minutes, only to find that I spelled "perimeter" wrong...

countjulu
Автор

So forum says that this works as well (worked for me)
// Write your function below.
// Don't forget to call your function!
var creditCheck = function (income)
{
if (income >= 100)
{
return "You earn a lot of money! You qualify for a credit card.";
}
else
{
return "Alas you do not qualify for a credit card. Capitalism is cruel like that.";
}
};
console.log(creditCheck(75));


darkoman
Автор

i dont have an answer for you now but i do have a link which you can find in the description

TheCodeAcademy
Автор

I killed about an 40 min., but i did it :D

var nameString = function(name) {
return "Hi, I am" + " " + name;

};
console.log(nameString);
nameString("Bobby");

edgarsbriezkalns
Автор

my video tags probably match what theyre adverting, i really dont know

TheCodeAcademy
Автор

this is wat my code looks lyk still it says..."It looks like your function doesn't return 'Alas you do not qualify for a credit card. Capitalism is cruel like that.' when the income argument is 75."

var creditCheck = function creditCheck(income){
if(income%3 >= 100){
console.log("You earn a lot of money! You qualify for a credit card.");
} else {
console.log("Alas you do not qualify for a credit card. Capitalism is cruel like that.");
}
};
creditCheck(75, 100, 125);

dhavaldabhi
Автор

just let it go, sorry for the bad words, i passed it :)

gabrielcassaro
Автор

I entered the exact code for lesson 1 on this and it says 'Oops, try again. It looks like your perimeterBox function doesn't return the correct perimeter (4) for a width of 1 and a length of 1.' Yet when I put perimeterBox(1, 1); I get a return of 2 instead of 4. 
// Write your function starting on line 3
var perimeterBox = function(legnth, width){
    return (length * 2) + (width * 2);
};
perimeterBox(1, 1);

YLCC
visit shbcf.ru