1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
'use strict'; export const convert = (number) => { const factorToSound = new Map([ [3, 'Pling'], [5, 'Plang'], [7, 'Plong'] ]); let drops = ""; for (const [factor, sound] of factorToSound) if (number % factor === 0) drops += sound; if (drops === "") drops += number; return drops; };