Battery Test
You have a list called "batteryPercentages" representing the battery percentages of devices indexed from 0 to n - 1.
Your job is to test each device sequentially starting from device 0. For each device:
If its battery percentage is greater than 0, increment the count of tested devices, decrease the battery percentage of all devices with higher indices by 1, and move to the next device.
If its battery percentage is 0, move to the next device without testing.
Print the total number of devices that will be tested.
Ada AI
I want to discuss a solution
Help me solve this
Give more examples
What's wrong with my code?
How to use 'for loop' in javascript?
javascript (node 13.12.0)