Good evening all,
I am trying to put the different concatenated variables onto different lines but am struggling. My code is shown below:
Good evening all,
I am trying to put the different concatenated variables onto different lines but am struggling. My code is shown below:
I figured it out. Need to put + “\n” + where you want the next line to be.
How do you type another line on the console without pressing enter?
Hi @CryptoDance,
Please understand the syntax of the console.log() first. You are seemingly getting confused in the syntax.
console.log is just a function that accepts parameters such as strings or variables. Each of them is seperated by a comma and the entire thing is encapsulated by brackets.
console.log("Hi my name is", name, "\n My age is", age, "\n Thank you"); // as you see i use "\n" for creating a new line.
Hope you understand better now.
Please send code snippets along with screenshots.
Also, how do I go to the next line of the console without hitting Enter?
I did this one using \n line breaks
Thanks for all your help! I really appreciate it and I apologize for being frustrated and needy.
Because they are strings and the console likes to show that it’s a string by decorating it with quotes. No need to worry about it.
You can very well do this -
console.log(`The rectangle is ${length) cm long and $(width)`)
You can read about it here - https://hacks.mozilla.org/2015/05/es6-in-depth-template-strings-2/
Hope this helps.
Yes this is fine. You have to use \n
Thanks so much!! I am finally moving along!!
@CryptoDance I don’t know which browser you are using, in Firefox you can switch to multi-line editor mode in Console, press Ctrl+B
. Then you will be able add multiple console.log
or any other statement and execute all at once when ready.
Thanks man. I figured it out to be shift-enter for both Safari and Firefox.
In the console of the Brave browser this works: [SHIFT] + [ENTER]