Code unit value in UTF-16

Report a typo

Write a JavaScript function that takes a character as input and returns its UTF-16 code unit value (in decimals) using the relevant method.

Sample Input 1:

😊

Sample Output 1:

55357
Write a program in JavaScript
function getCharCode(character) {
// Write your code here

}

/* Do not change code below */

process.stdin.setEncoding('utf8');

process.stdin.on('data', (data) => {
const inputCharacter = data.trim();

const codeUnitValue = getCharCode(inputCharacter);

process.stdout.write(codeUnitValue.toString());
});
___

Create a free account to access the full topic