Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function findNthDigit(inArr) {
- var number, reg,
- nthDigit;
- reg = RegExp(/\d/g);
- number = inArr[1].toString().match(reg);
- nthDigit = inArr[0];
- if (nthDigit > number.length) {
- return "The number doesn’t have" + nthDigit + " digits";
- }
- nthDigit = number[number.length - (nthDigit)];
- return nthDigit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement