When tracing out variables in the console, How to create a new line?

Leon Gaban picture Leon Gaban · Apr 26, 2013 · Viewed 129.7k times · Source

So I'm trying to do something simple, I want to break up my traces in the console into several lines, using 1 console.log statement:

console.log('roleName = '+roleName+' role_ID = '+role_ID+' modal_ID = '+modal_ID+\n+'related = '+related);

How would you write the above to trace out the following?

roleName = test
role_ID = test
modal_UD = test
related = test

instead of roleName = test role_ID = test modal_UD = test related = test

I've checked out several other questions which appear similar, but none have helped or are talking about a different thing.

Thanks for taking a look!

Answer

Selvakumar Arumugam picture Selvakumar Arumugam · Apr 26, 2013

You should include it inside quotes '\n', See below,

console.log('roleName = '+roleName+ '\n' + 
             'role_ID = '+role_ID+  '\n' + 
             'modal_ID = '+modal_ID+ '\n' +  
             'related = '+related);