You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Complete the function that accepts a valid string and returns an integer.
Wait, that would be too easy! Every character of the string should be converted to the hex value of its ascii code, then the result should be the sum of the numbers in the hex strings (ignore letters).
Examples
"Yo" ==> "59 6f" ==> 5 + 9 + 6 = 20
"Hello, World!" ==> 91
"Forty4Three" ==> 113
*/
export function hexHash(str:string):number {
return str.replace(/./g, x =>x.charCodeAt(0).toString(16)).match(/\d/g)?.reduce((a,c) => a + +c,0)?? 0