Reputation: 99
Do think you that it possible to remove the space in the console.log ?
For example on this code
for(var i=0; i<3 ; i++){
console.log("-");
}
I would like to display my dashes on a line.
-
-
-
By searching on StackOverFlow below, there is no solution visibly ?
Javascript: Remove white space of output array in browser console
Upvotes: 0
Views: 1419
Reputation: 67
I am not sure, if it is very important situation for you, you may write that way in case:
let str = '';
let x = 3;
let i = 0;
while(i<x){
str+='-';
if(str.length===x){
console.log(str);
}
i++;
}
But I would not recommend to type such inefficient way just for displaying in console. If you want to test inline console, use node.js with stdin and stdout.
Upvotes: 1
Reputation: 65845
If you log within the loop, then you are issuing multiple console.log()
commands and each will be on its own line.
If you record the value and concatenate that to a string, then you can log after the loop with one command.
let result = "";
for(var i=0; i<3 ; i++){
result += "-";
}
console.log(result);
Upvotes: 1
Reputation: 163488
No. The console is meant for output debugging only, and how it's presented is handled by the debugging tools. At best you can do this:
const line = [];
for(var i=0; i<3 ; i++){
line.push('-');
}
console.log(line.join(''));
Upvotes: 4