DEV Community

Discussion on: Feedback on my JavaScript project

 
alexanderjanke profile image
Alex Janke

Easiest would be to write a function setNewLetters (choose whatever name) in your script.js that sets the value for you.

// in script.js
export function setNewLetters(newValue) {
  if (!newValue) return;
  newLetters = newValue;
} 

So you can then call this function in your event listeners and update your variable this way. Skips passing values back and forth, back and forth.

Thread Thread
 
ptifur profile image
Y

Thanks for the insight!

Didn't know you can call the functions both ways. Guess this will save me some time stumbling through tutorials 😜