Files
30-seconds-of-code/test/sdbm/sdbm.js
2018-08-02 13:49:33 +03:00

10 lines
230 B
JavaScript

const sdbm = str => {
let arr = str.split('');
return arr.reduce(
(hashCode, currentVal) =>
(hashCode = currentVal.charCodeAt(0) + (hashCode << 6) + (hashCode << 16) - hashCode),
0
);
};
module.exports = sdbm;