Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can anyone explain this code in JavaScript?

I’m trying to create a sequence of sound frequencies for a project I’m working on. I’m not too experienced in JavaScript and came across this code that I’m thinking about implementing in my project; the problem is I’m not sure what it does. It looks like a key value function of some sort. Can someone explain this and if it is possible to add multiple values to the "values" part on the right side of the colon?

const freqMap = {
  1: 250,
  2: 329.6,
  3: 398,
  4: 462.2,
  5: 350,
  6: 400,
  7: 290,
  8: 300,
};

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It really is key value for example
freqMap['1'] or freqMap[1] will return 250 you can assign array to the value like so
const freqMap = { 1: [250, 300], ... };

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading