var symbol = "*"; var empty = ""; var count = 10; ********** ********** ********** ********** ********** ********** ********** ********** ********** ********** 

I need these characters to be displayed line by line in console.log(**********);

how to think about this logic when the interpreter stumbles upon the number 10 (in the context of this example, this figure is still static), so that it creates a new line console.log(**********); and so 10 times! what condition is needed for this, I think, here something is connected with the division by module, but it has not developed the logic itself! Thank you all in advance!

    2 answers 2

    You probably mean it?

     Array(count) // Мы тут создаем массив из `count` элементов .fill(symbol) // заполняем его Вашим символом 

    And for each element we perform:

     console.log(s.repeat(count)) // повторить символ `count` раз и вывести в консоль 

    the result is a 10х10 matrix

     var symbol = "*"; var count = 10; Array(count).fill(symbol).forEach(s => { console.log(s.repeat(count)); }); 

    • Imagine this is a chessboard! That same sample is needed - John
    • why symbol.length == 1 ?? I need the total number to be 100 - John
    • @John you still have questions? - Stranger in the Q

     var symbol = "*"; var empty = ""; var count = 10; for(let i = 0; i < count ; i++) { for(let j = 0; j < count ; j++) { empty += symbol; } console.log(empty); empty = ''; } 
    Or what is needed? Not quite clear.

    • I apologize, now I will attach the source code - John
    • So I can still come up with. - Alex Sazonov