top | item 46306342

(no title)

forgotmypw17 | 2 months ago

Wouldn't the correct answer be 5?

    result = result + x
    //   5   0        5

discuss

order

AlotOfReading|2 months ago

Iteration starts from the first element. X is 3, 3, then 5.

Daneel_|2 months ago

The logic results in 3 + 3 - 5 = 1, so it's not 5, sorry.

I'd love to know what logic path you followed to get 5 though!

commandlinefan|2 months ago

I did it in my head but got 4 (3 * 3 - 5), so I fail, too. Hopefully I'd be paying closer attention if I was actually applying for a job.

krackers|2 months ago

Presumably you'd get it if you short-circuited and didn't evaluate the else part.

forgotmypw17|2 months ago

Thanks to everyone who replied. I failed to account for the else condition when x is not > 3.

kevin061|2 months ago

3 comes before. Read it again.