Files
30-seconds-of-code/test/sdbm/sdbm.js
2018-01-17 13:40:40 -05: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