posted 6 years ago
Ok. I am totally new to programming and I'm starting a project. I'm not even really sure how to ask the question but here it goes.
I have an array. I want to use a loop to go through and look at each individual element in the array compare it to a number then if its greater than, equal to, or less than that value, do a math operation to that variable. After the loop runs the variable will be set to the number it should be after each individual check is done.
As the loop runs it may add 1 to the value on the first element then on the second element it may subtract 1 from the value and on the 3rd it may do nothing to the value. I dont want the value of the variable to be overwritten each element, only adjusted from its current value on each loop.
this is my attempt at it but i'm having a difficult time wrapping my head around loops and arrays.
thanks in advance for any guidance.
example: