Plz help


#1

so i am learning JS and i made a variable but the variable won't show up where the code shows up plz help

var morningAlarm = '6:30 AM';

console.log('Morning alarm is set to: morningAlarm');


#2

Hi @giganinja51438

In order for it to show up you can use the plus sign to concatenate the string and var like this,

console.log('Morning alarm is set to: ' + morningAlarm);


#3

console.log('Morning alarm is set to: morningAlarm');

when the quotes are used, the code will read it as a sentence, it wont do the command. If you want it to read your variable, if you put the variable outside, and then add the quote - - it will work :smiley:

console.log('Morning alarm is set to:' + morningAlarm)

kinda like if you type

console.log("console.log")

it won't read the second one.


#4

I fixed it i asked my friend and pointed out i needed to add a comma


#5

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