This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Samuel Waters
about 9 years

26/28

help

Answer 54ecf6f895e378f07e000172

0 votes

Permalink

What’s the problem?

points
Submitted by Neil
about 9 years

1 comments

Louis Winfield about 9 years

Hello SAMMY BOY

Answer 54edb3e19376760f7d0013d7

0 votes

Permalink

// On line 2, declare a variable myName and give it your name. var myName = “Yura” // On line 4, use console.log to print out the myName variable. console.log(“Yura”); // On line 7, change the value of myName to be just the first 2 // letters of your name. myName = (“Yura”.substring(0,2)); // On line 9, use console.log to print out the myName variable. console.log(“Yu”);

points
Submitted by Louis Winfield
about 9 years

3 comments

Neil about 9 years

Don’t mark your own code up. It’s bad code. Once you have declared the variable and assigned it a value you NEVER retype that value again. eg. line 7 should be myName = myName.substring(0,2); DON’T retype the strings!!

Louis Winfield about 9 years

but it works so how is it bad?

Neil about 9 years

Because you are retyping out the values. What if the value changed? The way you have coded it you’d have to go through your whole code changing each instance. If your code was 20000 lines long that could take a while :)