javaScript Programming: Lesson 9 of 38: Practice exercise 3

Good evening all,

I am trying to put the different concatenated variables onto different lines but am struggling. My code is shown below:

1 Like

I figured it out. Need to put + “\n” + where you want the next line to be.

1 Like

You can also use multiple console.log() statements

1 Like

How do you type another line on the console without pressing enter?

Can someone please help? I have tried all these combinations:

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?
image

I did this one using \n line breaks
image

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. :slight_smile:

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.

1 Like

Yes this is fine. You have to use \n

1 Like

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.

1 Like

In the console of the Brave browser this works: [SHIFT] + [ENTER]

1 Like