+ 1

How can I get an array of numbers of 10 figures? in Js

Asking for Only javascript developers

15th Jul 2020, 6:55 AM
Shantiram Niraula
Shantiram Niraula - avatar
6 Respuestas
+ 2
const nums10digits = array.map(a => a.match(/^\d{10}$/));
15th Jul 2020, 7:52 AM
Calviղ
Calviղ - avatar
+ 1
You should've known all these things from the JavaScript course. Head there and check out the for loops section to be reminded how to make one, and the rest I have already given you in my answer.
15th Jul 2020, 7:25 AM
coddy
coddy - avatar
0
You could make a new array (array = [];) and then use a for loop and array.push() to add the elements in the loop. Should work w/ any number.
15th Jul 2020, 7:02 AM
coddy
coddy - avatar
0
Could you show plz Coder's Crux?
15th Jul 2020, 7:05 AM
Shantiram Niraula
Shantiram Niraula - avatar
0
Calviղ You've not only spoonfed him the code, but you also made it a one liner, which makes it tougher to understand for beginners. That's your choice on the matter, but please don't give people the answer straight away.
15th Jul 2020, 9:22 AM
coddy
coddy - avatar
0
Coder's Crux If you are here for long, you would understand I always help beginners by given solutions, especially the simple question like this. This is the simple map method oneliner, it's best to demonstrate for beginners to learn to write effective codes.
15th Jul 2020, 10:04 AM
Calviղ
Calviղ - avatar