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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️