Change variable example


#1


CHANGE VARIABLE EXAMPLE
// On line 2, declare a variable myName and give it your name.
var myName = "Jobinmathew"
// On line 4, use console.log to print out the myName variable.
console.log("JOBIN")
// On line 7, change the value of myName to be just the first 2
// letters of your name.
myName="Jo"
// On line 9, use console.log to print out the myName variable.
console.log("JOBIN")

ITS LOOK LIKE YOU DIDNT LOG YOUR WHOLE NAME TO THE CONSOLE

Replace this line with your code.


#2

PLEASE HELP ME.I DIDNT UNDERSTAND WHATS WRONG IN THIS.ITS IN THE VARIABLE EXAMPLE.i understand what is this is
var pool="john is good"
console.log("pool".substring(0,2))
so pool is converted in to john is good right?and the console log is counting "john is good "?am i right?.then why my code is incorrect above


#3
console.log(myName);

Programmatically we would use the .substring() method as you have done here,

myName = myName.substring(0,2);

#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.