My output right now is this: Output
My code is:
var a = [2, 4];
var b = [5, 6];
console.log(a, "\n", b);
I want the output to look like this:
[2, 4]
[5, 6]
My output right now is this: Output
My code is:
var a = [2, 4];
var b = [5, 6];
console.log(a, "\n", b);
I want the output to look like this:
[2, 4]
[5, 6]
Here's one way:
var a = [2, 4];
var b = [5, 6];
console.log('',a,'\n',b)
console.log, when you set the first argument as a string, it considers the format as a string. Meaning, arguments that follow the string will also be considered strings. - If you use any other format for the first argument then it won't output the way you expect because it won't assume the rest of your arguments as strings. When using '\n' string format is required.I think you can use
var a = [2, 4];
var b = [5, 6];
console.log(a + "\n" + b);
It's working for me.
You can use this:
console.log(`${a}\n${b}`);
Try using the array.toString() function.
var a = [2, 4];
var b = [5, 6];
console.log(a.toString() + '\n' + b.toString())
This code would return:
2,4
5,6