Write a JavaScript function that checks whether a given character has surrogate pairs to represent it. The function should return true if the character requires surrogate pairs, and false if it doesn't.
Unicode functions
Surrogate pair check
Report a typo
Sample Input 1:
🐇Sample Output 1:
trueWrite a program in JavaScript
const readline = require('readline');
/* Do not change code above */
function hasSurrogatePairs(char) {
//Write your code here
}
/* Do not change code below */
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
encoding: 'utf16le',
});
let character = '';
rl.input.on('data', (data) => {
character += data;
});
rl.on('close', () => {
console.log(hasSurrogatePairs(character));
});
rl.question('', () => {
rl.close();
});
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.