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

Easy, \n needs to be in the string.


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);

In ES6/ES2015 you can use string literal syntax called template literals. Template strings use backtick character instead of single quote ' or double quote marks ". They also preserve new line and tab

const roleName = 'test1';
const role_ID = 'test2';
const modal_ID = 'test3';
const related = 'test4';
        
console.log(`
  roleName = ${roleName}
  role_ID = ${role_ID}
  modal_ID = ${modal_ID}
  related = ${related}
`);