String to a Unicode code points array

Report a typo

Build a JavaScript function that takes a string as input and returns an array of all the Unicode code points for each character in the string.

Sample Input 1:

Hello TARDIS!

Sample Output 1:

[ 72, 101, 108, 108, 111, 32, 84, 65, 82, 68, 73, 83, 33 ]
Write a program in JavaScript
function getCodePoints(str) {
var codePoints = [];
/* Do not change code above */

//Write your code here

/* Do not change code below */
return codePoints;
}

process.stdin.once('data', (input) => {
const inputString = input.toString().trim();
const result = getCodePoints(inputString);

console.log(result);

process.stdin.pause();
});
___

Create a free account to access the full topic