JavaScript #25


#1

can anybody help me with this, please
JavaScript #25
console.log (var myName === "myCountry")
console.log ("myCountry".substring(0,3));
julia_programmer
26m

Ops, tente outra vez. There was a problem with your syntax.
julia_programmer
1m

help help help give me a hint, please. what i did wrong?


#2

first you must declare myName variable then you can finally do

console.log (myName === "myCountry")

if the intention was to use whatever was stored in myName then you can use myName instead of "myCountry" after you define it


#3

rydan, here what I did

console.log (myName === "myCountry")
console.log("myCountry".substring(0,4))

& it says:"Ops, tente outra vez.
Did you declare a variable called myCountry?
&ReferenceError: myName is not defined "


#4

var "myCountry" === "MyName";
console.log("myCountry".substring(0,3));
console.log("myCountry" === "myC");
it's the last one


#5

// = is the assignment operator use to assign variables
//but
//=== is a comparison operator use to compare two things
var myCountry = "Canada";
var myName = "julia_programmer";
console.log(myCountry === myName); //false

your code should look something like this .Now use this together with the instructions to correct your code and see if you pass


#6

// Declare a variable on line 3 called
// myCountry and give it a string value.
var "myName" = "myCountry";

// Use console.log to print out the length of the variable myCountry.
console.log("myCountry".substring(0,3));

// Use console.log to print out the first three letters of myCountry.
console.log("myCountry" === "myC");
SyntaxError: missing variable name


#7

Variable names cannot be strings(i.e. surrouded in quotes)

Since you have stored "myCountry" in a variable before. you can simply call the substring() method on that variable instead

Meaning where ever you call myName is the same thing as saying "myCountry"


#8

// Declare a variable on line 3 called
// myCountry and give it a string value.
var myName = "myCountry";

// Use console.log to print out the length of the variable myCountry.
console.log("myCountry".substring(0,3));

// Use console.log to print out the first three letters of myCountry.
console.log("myCountry" === "myC");
Ops, tente outra vez. Did you declare a variable called myCountry?
myC
false


#9

I think the variable name should be myCountry instead

no quotes since myCountry is supposed to be a variable


#10

// Declare a variable on line 3 called
// myCountry and give it a string value.
var myCountry = "myName";

// Use console.log to print out the length of the variable myCountry.
console.log("myCountry".substring(0,3));

// Use console.log to print out the first three letters of myCountry.
console.log("myCountry" === "myC");
Ops, tente outra vez. It looks like you didn't log the length of myCountry to the console.
myC
false


#11

you have to log the length of what is stored in myCountry to console

console.log(myCountry.length);

bu you have to get rid of the quotes around myCountry


#12

thank u, but it didn't work


#13

var myCountry = "myName";

// Use console.log to print out the length of the variable myCountry.
console.log(myCountry.length);//6

// Use console.log to print out the first three letters of myCountry.
console.log(myCountry.substring(0,3)); //myN

#14

thank u, rydan :kissing_smiling_eyes: