mastapegs/js-marathon-web-audio-api

Refactor Keyboard Logic

Opened this issue · 0 comments

This logic is pretty messy. We could refactor it in several ways:

  • Use Array.prototype.map instead of .forEach
  • Refactor IIFE

(() => {
const keys: Array<ReactNode> = [];
noteFreq.forEach((octaveTable, octave) => {
const keyList = Object.entries(octaveTable);
keyList.forEach((key) => {
keys.push(<Key note={key[0]} octave={octave} freq={key[1]} />);
});
});
return keys;
})()}