Answers for "how to take range value in js"

16

range javascript

[...Array(5).keys()];
 => [0, 1, 2, 3, 4]
Posted by: Guest on May-20-2020
0

range in javascript

// while ES6 does not have any similar methods built-in 
// the same basic functionality can be implemented by:
[...Array(5).keys()];
 => [0, 1, 2, 3, 4] 

String.fromCharCode(...[...Array('D'.charCodeAt(0) - 'A'.charCodeAt(0) + 1).keys()].map(i => i + 'A'.charCodeAt(0)));
 => "ABCD"

//               OR             //

function range(size, startAt = 0) {
    return [...Array(size).keys()].map(i => i + startAt);
}

function characterRange(startChar, endChar) {
    return String.fromCharCode(...range(endChar.charCodeAt(0) -
            startChar.charCodeAt(0), startChar.charCodeAt(0)))
}
Posted by: Guest on November-01-2021

Code answers related to "how to take range value in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language