JavaScript: Populate Hash Table with String Character Counts

Using hash table, split() and forEach()

nick3499
1 min readJun 2, 2018
Node.js REPL

Execute the Script

In a Unix-like terminal:

$ sudo node charCounts.js

Result

{ a: 2, b: 1 }
{}

Hash Table

In the hash table above, { a: 2, b: 1 }, the keys a and b were mapped to the values 2 and 1.

forEach()

Array.prototype.forEach()

--

--

nick3499
nick3499

Written by nick3499

coder of JavaScript and Python

No responses yet