Last updated 4 years ago
Was this helpful?
value 2 is equal to '10'
value 1 is equal to '1'
Repeat the string '10' by the quotient of 'size' divided by 2.
attach '1' character if size divide 2 remainder 1
const stringy = (size) => '10'.repeat(Math.floor(size / 2)) + '1'.repeat(size % 2);