C
C#•13mo 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
jsOP•13mo ago
i tried inpurtting the targetChange variable after max like that but it gave me errors which i dont understand
No description
Omnissiah
Omnissiah•13mo ago
you are not closing the (
js
jsOP•13mo ago
it still gives me the max of the array
No description
js
jsOP•13mo ago
i just get 200 outputted everytime even if i input like 60
Patrick
Patrick•13mo ago
well yes because that's the maxinum number in the array that's what Max does
js
jsOP•13mo ago
do i need to use a loop and stop when it gets to one bigger
Patrick
Patrick•13mo ago
that would be a good start
js
jsOP•13mo 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•13mo ago
$helloworld
Want results from more Discord servers?
Add your server