I am having trouble with 24. Variables need help


#1

I am having trouble with 24. Variables and need help I coded console.log(var myAge===25); and it still said something is wrong I tried different ways to code it and still got it wrong. Any one got some pointers or can be of some assistance?


#2

you have all the right elements just the wrong order.
Define the myAge variable

var myAge = 25

then console log myAge.

console.log (myAge);

Also, for defining variables only use 1 equals sign.
1 equals sign is used for assignment.
2 and 3 are used for comparison.


#3

Doing

Means to print "var myAge===25".

-----------------------------------------------------------------

@zeroclifawn Seems to have said what I was about to say, so I will just say this:

You must define the variable, then print it using console.log.

Example

var ____ = 14

console.log(____);

THIS PRINTS 14


#4

Thank you guys I appreciate that.


#5

Hey @ragezapper or @zeroclifawn I'm also having trouble with 25. More Variable Practice I'm stuck once again. Here is what I have...
// Declare a variable on line 3 called
// myCountry and give it a string value.
var myCountry=Ethiopia;
myCountry.substring(0,5)

// Use console.log to print out the length of the variable myCountry.
var myCountry=Ethiopia
console.log(myCountry.substring(0,10));

// Use console.log to print out the first three letters of myCountry.
var myCountry=Ethiopia
console.log(myCountry.substring(0,4));
Can you guys give me some examples of what to do I would appreciate it thanks.


#6

Having the same problem. Would really appreciate anyone with help.


#7

when defining a string value make sure you put it in quotes.
Ex. var thing = "Things"

also you only have to type your variable in once and it will be remembered as myCountry for the rest of this exercise.


#8

To make this easier to classify, I'll show you the ways I'm gonna explain it:

Now let's start!:smiley:

Well, as @zeroclifawn had said, you need to define your variable as a string:

var ___ = "_____"

And you see the "substring" functions you put? You only need one of the ones you put. These are not needed:

In your first part, it just said to declare your variable as a string, so you don't have to do anything with the substring function.

In the second part, it just says to print the length of myCountry. You already defined myCountry as Ethopia (if you wrote it as a string), so you do not have to write it again.

This part from the second part can be taken out, and this from the third part:

From the second part, it says you need to print the length of myCountry. Do you remember the function of .length?

console.log(myCountry.length) //prints the length of Ethopia

SO:

In other meanings, you don't need this:

Now, we're going to your third part.

(REMEMBER TO TAKE OUT THE DECLARATION OF THE VARIABLES)

Remember, in codes, everything starts with 0, and you have to print the first three letters of myCountry.

E t h o p i a
0 1 2 3 4 5 6

To print the first three letters, you must do (0,2), as shown in the diagram above.

Hope it helped!:smiley:


#9

It most definitely did thanks guys.


#10

I Can not see any diagram @ragezapper , please can you show me the diagram as i am also stuck there too


#11
E t h o p i a
0 1 2 3 4 5 6

#12

I need help can u guys help me?
{
console.log(myAge);
}
var varName = data ;

var myName = Leng ;

var myAge = 14;

var isOdd = true;

var variableName = 14 ;


#13

Mine keeps saying: It looks like myAge isn't a number.
This is my code
var myAge = /* 14 */

console.log(myAge);


#14

/* and */ means to make it as a comment. :smiley:

Except, unlike //, you can do /* with a long span of lines, not only one.

Problem: / and /


#15

{
console.log('myAge');
}
var varName = 'data' ;

var myName = 'Leng' ;

var myAge = 14 ;

var isOdd = true ;

var variableName = 14 ;
Thanks peeps this is what I got :smirk: :smiley:

[quote="ragezapper, post:14, topic:9112, full:true"]
/* and */ means to make it as a comment. :smiley:


#16

Hi all!

Also facing a problem with exercie 24, on variables:
current code looks like this:

if( 10 % 7 === 0 ) {
console.log("The first number is even");
} else {
console.log("The first number is odd");
}
var myAge = "30";
console.log (myAge);

Yet when I try and save and progress I get a message saying : "oops, looks like myAge; isn't a number"??
Even though it is!....Where am I going wrong with this?


#17

Hey @bitmaster28787,

You put 30 as a string here :smiley::


#18

Still not getting it, can you just give me the answer


#19

Hi can you post your code ?


#20

guys i need serious help nothing is working plezzzzzzzzz:flushed::fries::poultry_leg:







:camera: