Solving a code challenge

PHOTO EMBED

Mon Jun 13 2022 20:35:06 GMT+0000 (Coordinated Universal Time)

Saved by @soyreynald #javascript

// Write your code here   
let x1Position = x1
let x2Position = x2
const x1BiggerAndFaster = x1 >= x2 && v1 >= v2
const x2BiggerAndFaster = x2 >= x1 && v2 >= v1
do {
  const positionMatch = x1Position === x2Position;
  if (positionMatch) {
    return 'YES';
  }
  const x1PositionPassedx2Positon = (x1 >= x2) && (x1Position < x2Position)
  const x2PositionPassedx1Positon = (x2 >= x1) && (x2Position < x1Position)
  const cannotMatch = x1BiggerAndFaster || x2BiggerAndFaster || x1PositionPassedx2Positon || x2PositionPassedx1Positon
  if (cannotMatch) {
    return 'NO';
  }
  x1Position += v1
  x2Position += v2
} while (true)
content_copyCOPY

This is from HackerRank challenge: Kangoroo

https://www.hackerrank.com/challenges/kangaroo/problem?isFullScreen=true