Max Profit Coding Challenge

Hello! I need some explanation and clarification about Max Profit coding challenge, because I didn’t understand the FCC explication. I translated into my native language, but I couldn’t understand it, too. Here is the coding challenge for today:

Max Profit

Given an array of daily stock prices and a budget (in dollars), calculate the maximum profit you could make by buying and selling the stock over the given period.

You may only sell after you buy.

You can only buy whole shares.

Return the maximum possible profit as a string, rounded down to the nearest cent and formatted to two decimal places.

Tests:

Waiting:1. getMaxProfit([5, 6], 50) should return “10.00”

how much are you aware of the stock market?
stock market prices change often a lot

in this case, one share (which is a fraction of a company) costs 5 on day 1, and cost 6 on day 2

you have 50$ available, so on day 1 you buy as many shares as you can, which means 50/5 = 10 shares. Then on day 2 you sell each of these shares for 6, so you sell for 6*10=60

the profit is the difference between money in and money out, so 60-50, the profit is 10

this is the link to the challenge
https://www.freecodecamp.org/learn/daily-coding-challenge/2026-07-02

Thank you so much for your clarification and explanation! I’ll try to resolve the coding challenge.