• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Identifying an array using a string JavaScript

Resolved: Identifying an array using a string JavaScript

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I am having difficulties with returning a pre-declared array from user feedback. This is an exercise meant to help me understand how to take user input using a drop-down in HTML and return a value based on a script.
What I want the second part of the script to do is return the array whose name is the string selected by the user.
I have tried not using String() in the second part but it did not change anything. Array.isArray() doesn’t seem to work, either, so it’s clear that the editor doesn’t see a connection between the array names and the strings.
Would appreciate any feedback telling me what to look into or suggestions for solutions.
Thanks a lot!

Answer:

If I’m not mistaken you could use var instead of const this way variables would not be scoped and attached to the global object window and so be accessible using window[name].
try

If you have better answer, please add a comment about this, thank you!

arrays javascript
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: how to get and read an xml file in a zip file using xml.etree

02/04/2023

Resolved: The ‘Access-Control-Allow-Origin’ header contains multiple values ‘*, *’, but only one is allowed. cors error not resolving

02/04/2023

Resolved: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘crm.email’ doesn’t exist (Connection: mysql, SQL: select count(*) as aggregate from `email`

02/04/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.