How to rewrite a numeric variable into an array without array methods?
-
Let's say there is
let x = 12345;
let arr = [];
how to convert each digit of the x variable into an element of the arr array without array methods to get something like this:
arr = [1, 2, 3, 4, 5];JavaScript Lilah Middleton, May 18, 2019 -
new Number(12345).toString().split('');
// Если нужна типизация элементов, то:
new Number(12345).toString().split('').map(i=>+i);Joshua Holt
1 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!