From a908c877629b5f8fe2bbb469e8cd0d2c0c9a242b Mon Sep 17 00:00:00 2001 From: pixelzoom Date: Mon, 20 Sep 2021 17:04:53 -0600 Subject: [PATCH] document why I'm using for instead of map, https://github.com/phetsims/fourier-making-waves/issues/165 --- js/discrete/view/FourierSoundGenerator.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/discrete/view/FourierSoundGenerator.js b/js/discrete/view/FourierSoundGenerator.js index a87bc9fa..c4e48f46 100644 --- a/js/discrete/view/FourierSoundGenerator.js +++ b/js/discrete/view/FourierSoundGenerator.js @@ -42,7 +42,9 @@ class FourierSoundGenerator extends SoundGenerator { ); // {OscillatorSoundGenerator[]} Create an oscillator for each harmonic. - const oscillatorSoundGenerators = []; //REVIEW: = fourierSeries.harmonics.map( harmonic => ... )? + // Using for loop here instead of map, because we need to connect each OscillatorSoundGenerator to the + // masterGainNode, and map should not have side-effects. + const oscillatorSoundGenerators = []; for ( let i = 0; i < fourierSeries.harmonics.length; i++ ) { const harmonic = fourierSeries.harmonics[ i ]; const oscillatorSoundGenerator = new OscillatorSoundGenerator( {