Answer the question
In order to leave comments, you need to log in
How can I make even tabs in a line?
How can I implement even indentation depending on the lines?
There is a line, I need to somehow count the number of characters in all lines, and where there are more characters, from there attach tabs, 4 spaces, spaces are needed where it is \t
.
The line itself:
let text =
'\n\
Склад:\t\t50 из 100\n\
Заказано:\t\t%s\n\
\tВведите сколько желаете заказать:'
'\n\
Склад: 50 из 100\n\ // тут получается 11 пробелов, так как тоже ст. 2 длиннее
Заказано: 5\n\ // ст2. тут получается 8 пробелов, самая длинная строка
Остаток: 50\n\ // тут получается 5 пробелов, так как ст.2 длине на один сим.
Введите сколько желаете заказать: // Тут только 4, так как перед строкой нет символов '
Answer the question
In order to leave comments, you need to log in
How can I make even tabs in a line?
I need to somehow count the number of characters in all strings
text.split('\n').forEach(
(s,i)=>console.log('Символов в строка №'+(i+1)+': '+s.length)
);
I don’t know if there is a prinf function in JS or its analogue, but it is what you need.
Here is something similar https://stackoverflow.com/questions/17224130/forma...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question