Find minimum in subarray

Find index of minimum value in a subarray

Finish writing the function indexOfMinimum, which takes an array and a number startIndex, and returns the index of the smallest value that occurs with index startIndex or greater. If this smallest value occurs more than once in this range, then return the index of the leftmost occurrence within this range.

Here’s my work in Ruby:


and in js, with a while loop:


Still getting used to javascript syntax with all the semi-colons and parentheses..

Also, a note on the ‘for’ loop:

for (initializer; condition; iterator) {

    // statement(s)


Find minimum in subarray

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s