×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

array input value how to replace decode value as Output using JavaScript code

array input value how to replace decode value as Output using JavaScript code

array input value how to replace decode value as Output using JavaScript code

(OP)
Hi

I have dynamic input array variable value
Decode values
1-->Java
2-->HTML
3-->SQL
4-->PHP
5-->DOTNet
6-->JavaScript
7-->Oracle

input values
arrstrval =1,2,5,4,7

but my output should be like below
arrstrval =Java,HTML,DOTNet,PHP,Oracle

Can any one help me Please

RE: array input value how to replace decode value as Output using JavaScript code

Hi

Assuming you not need compatibility with Explorer 8 and older, a simple Array.map() call should do it.
Here you can see how I used it in the browser's console :

CODE --> Console

13:51:16.714language_list = [undefined, 'Java', 'HTML', 'SQL', 'PHP', 'DOTNet', 'JavaScript', 'Oracle']
13:51:16.747 ⇦ ‣ Array(8) [ undefined, "Java", "HTML", "SQL", "PHP", "DOTNet", "JavaScript", "Oracle" ]

13:51:30.152arrstrval = [1, 2, 5, 4, 7]
13:51:30.179 ⇦ ‣ Array(5) [ 1, 2, 5, 4, 7 ]

13:51:38.250arrstrval.map(value => language_list[value])
13:51:38.279 ⇦ ‣ Array(5) [ "Java", "HTML", "DOTNet", "PHP", "Oracle" ] 

Feherke.
feherke.github.io

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close