Got stuck on Ball Upwards challenge

I got stuck on Ball Upwards challenge on codewars.
I think that I don’t understand the problem properly. I need some explanation to understand the problem. Also I need tips to help me solve the challenge.

My Code so far:

function maxBall(v0) {
  let v = Math.round((v0 * 1000) / 3600);
  let g = 9.81;
  let t1 = v / 10;
  let t2 = ((v / 10) * 10 + 1) / 10;
  let h1 = v * t1 - 0.5 * g * t1 * t1;
  let h2 = v * t2 - 0.5 * g * t2 * t2;
  let result1 = ((t1 * 10) / 10) * 10;
  let result2 = ((t2 * 10) / 10) * 10;
  console.log(res1, res2, h1, h2);
  return h2 < h1 ? result1 : result2;
}

The link to the challenge:

I have working code but I will give you only a hint :grinning:

Consider having a loop in which time increments.

1 Like

Thank you @Archibald
Could you give me more hints :slight_smile: !!!

Continue looping until the ball starts to go down :grinning:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.