Create a JavaScript program to decode hashes as backspaces and return the deleted string. code example
Example 1: delete backspace on string js
var str1 = 'Hello world xd lol'
var str2 = ''
str2 = str1.replace(/\s/g, '')
console.log(str2)
Example 2: javascript hash string
function hashFnv32a(str, asString, seed) {
var i, l,
hval = (seed === undefined) ? 0x811c9dc5 : seed;
for (i = 0, l = str.length; i < l; i++) {
hval ^= str.charCodeAt(i);
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
}
if( asString ){
return ("0000000" + (hval >>> 0).toString(16)).substr(-8);
}
return hval >>> 0;
}
Example 3: java script hash
function hashFnv32a(str, asString, seed) {
var i, l,
hval = (seed === undefined) ? 0x811c9dc5 : seed;
for (i = 0, l = str.length; i < l; i++) {
hval ^= str.charCodeAt(i);
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
}
if( asString ){
return ("0000000" + (hval >>> 0).toString(16)).substr(-8);
}
return hval >>> 0;
}