Files
30-seconds-of-code/test/sdbm/sdbm.js
2018-02-04 17:38:39 +02:00

9 lines
209 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;