C
C#•8mo ago
js

max function in arrays

i am writing a program to output change for a vending machine in the minimum amount of coins. I want a way to select the corrent number from the array which is closest to the change value which is inputted for example: input 65, the closest value would be 50. I am sorry if my code is bad im really new
No description
10 Replies
js
js•8mo ago
i tried inpurtting the targetChange variable after max like that but it gave me errors which i dont understand
No description
not guilty
not guilty•8mo ago
you are not closing the (
js
js•8mo ago
it still gives me the max of the array
No description
js
js•8mo ago
i just get 200 outputted everytime even if i input like 60
Patrick
Patrick•8mo ago
well yes because that's the maxinum number in the array that's what Max does
js
js•8mo ago
do i need to use a loop and stop when it gets to one bigger
Patrick
Patrick•8mo ago
that would be a good start
js
js•8mo ago
school making me use c# im so bad 😭 i cld do it in py u know any good places to learn for a complete noob
TheRanger
TheRanger•8mo ago
$helloworld
Want results from more Discord servers?
Add your server
More Posts