-1

As you know the Maht.min(5,10,3,17) will return "3" as answer. I'm looking for ability to return related Text for each number. For example it was Math.min(5|A,10|B,3|C,17|D) and then result return "C". How can I do this by JS? I'm looking for Related Text come from Finding Lower Number related text.

Thank you

1 Answers1

0

Well, You can achieve this by using Object. You can use Math.min() to find the minimum number. And when you'll get the number you can access the object to check the related alphabet to that number. As e.g

const minimumNumber = Math.min(5,10,3,17);

const alphabet = { '5': 'A', '10': 'B', '3': 'C', '17': 'D' };

const relatedAlphabet = alphabet[minimumNumber];

Note:

You Can not access object with dot(.) notation if the key of an object is number. So you can access them like arrays.

Community
  • 1
  • 1