Ad
  • Custom User Avatar

    Thanks, jlubiba! I appreciate it.

  • Custom User Avatar

    Here the issue is that you have re-declared the your variable again, and you have not added an element to separate the variable from the string in the console.log().

    • First, since you've already declared the var myName, you do not need to re-declare it by typing "var" before the variable anymore.
    • Second, for your code to be able to understand that you want for it to run a string (any element in quotation mark) and a variable, you have to use " 'string ' + variableName" or " 'string', variableName".
      Note that when using the +, which is called the concatenate operator and is used to combine strings and other elements, I would advice to leave a space at the end of the string so that the string and the variable are not stuck together when printed.
      But when using the , it automatically leaves a space between the two elements.
    var myName = 'Elijah'
    console.log('My name is: ' + myName);
    
    or
    
    console.log('My name is:', myName);
    
    • A third option would be to declare you variable inside of the console.log by using template literals. These allow for one to put strings and variables together as easiliy aas the example below: But the variable has to be inside of ${The variable would be here}, it can be declared here or just called in here
    console.log(`My name is: ${var myName = "Elijah"}`);
    
    or 
    
    var myName = "Elijah"
    console.log(`My name is: ${myName}`);
    

    I hope that it helps. Keep up the good work.