This forum is now read-only. Please use our new forums! Go to forums
26/28
help
Answer 54ecf6f895e378f07e000172
Answer 54edb3e19376760f7d0013d7
// 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”);
3 comments
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!!
but it works so how is it bad?
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 :)
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
1 comments
Hello SAMMY BOY