UNPKG
@ahsolo/lotide
Version:
latest (1.0.2)
1.0.2
1.0.1
1.0.0
lotide assignment for Lighthouse Labs coding bootcamp
github.com/ahSOLO/lotide
ahSOLO/lotide
@ahsolo/lotide
/
letterPositions.js
13 lines
(12 loc)
•
315 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
const
letterPositions =
function
(
sentence
) {
let
results = {};
for
(
let
i =
0
; i < sentence.
length
; i++) {
if
(results[sentence[i]]) { results[sentence[i]].
push
(i); }
else
if
(sentence[i] !=
" "
) { results[sentence[i]] = [i]; } }
return
results; };
module
.
exports
= letterPositions;