DEV Community

Cover image for Array Index != Array Min/Max Value
commdao
commdao

Posted on

Array Index != Array Min/Max Value

In this coding journey, I've severely underestimated how much utility goes into using an array. If you take a peek at some coding interview questions, you'll see lots of array stuff too!

Edabit gave me the challenge of "Finding the Smallest and Biggest Numbers" within an array of numbers.

When I first took it to task, I made the mistake of confusing that for the index (i.e. the placement order of the numbers). I mean, it made sense to me since the example arrays where in numerical order.

Why wouldn't arr[0] always be the smallest number?

Mild spoilers: you'll need to learn Math.min and Math.max.

TL;DR placement is placement. Value is value. Placement != value.

Top comments (0)