+ 2
How to print this pattern In JavaScript without using document.write()
* ** *** **** *****
9 ответов
+ 9
Alright, then I'll give my solution too:
for(i of [1, 2, 3, 4, 5])
console.log('*'.repeat(i));
(We should prefer to just give hints so that the user learns something by trying themselves!)
+ 5
Bilal Yoosuf We can do using console.log
Check this
for (var i = 0; i < 5; i++) {
var a = "";
for (var j = 0; j <= i; j++) {
a = a + "*";
}
console.log(a);
}
HonFu is right.
+ 4
Use console.log instead.
+ 3
Not (hint) if you create each line before you log it. 😉
+ 3
Create <pre> </pre> area, and change innerHTML.
+ 3
Thanks everyone for the answers. I understood the mistake I made while using console.log().
+ 2
HonFu If we use console.log we won't get the pattern like this. Console.log automatically choose the next line always.
+ 2
I mean something like this https://code.sololearn.com/WWnA0hV7if7T/?ref=app
0
And my solution.
https://code.sololearn.com/WIVh5LDViJcK/?ref=app