const changeArray = (array, number) => {
let count = new Map();
const result = [];
 
array.forEach(item => {
if (count.has(item)) {
if (count.get(item) < number) {
result.push(item);
count.set(item, count.get(item) + 1);
}
} else {
result.push(item);
count.set(item, 1);
}
});
return result;
};
 
const rot13 = message => {
const UPPER_START = 65;
const UPPER_END = 90;
const LOWER_START = 97;
const LOWER_END = 122;
const ALPHABET_SIZE = 26;
const result = message.split('').map(item => {
if (UPPER_START <= item.charCodeAt(0) && item.charCodeAt(0) <= UPPER_END) {
return String.fromCharCode(
((item.charCodeAt(0) - UPPER_START + 13) % ALPHABET_SIZE) + UPPER_START
);
} else if (LOWER_START <= item.charCodeAt(0) && item.charCodeAt(0) <= LOWER_END) {
return String.fromCharCode(
((item.charCodeAt(0) - LOWER_START + 13) % ALPHABET_SIZE) + LOWER_START
);
} else {
return item;
}
});
return result.join('');
};
 
const getHexDecimal = (r, g, b) => {
const system = 16;
 
const toHex = n => {
const clamped = Math.min(Math.max(n, 0), 255);
const hex = clamped.toString(system);
if (hex.length < 2) {
return '0' + hex;
}
return hex;
};
return (toHex(r) + toHex(g) + toHex(b)).toUpperCase();
};
 
Click Run to execute JavaScript.
Code runs in an isolated environment.