Match one list with one list

Asked 2 years ago, Updated 2 years ago, 81 views

Let's say we have the following code.

const a = ["a", "b", "c"];
const b = [1, 2, 3];
console.log(/*processed value*/);

So when we put "a" in a, let's have 1 in b Is there only one way to get the number from one list and then the value of the number from another list?

javascript keyboard

2022-09-20 17:09

1 Answers

I think this will work.

const a = ["a", "b", "c"];
const b = [1, 2, 3];
var n = a.indexOf(input);
console.log(b[n]);


2022-09-20 17:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.