Javascript Challenge
Started on: 31 July 14
Participants: 1
While playing the 'The Running Man' show, I have to survive 9007199254740992 times but all the gamers have been killed even though they have been playing bravely, could anyone help solve the challenge?
The following code could make crash your browser!! Be careful!!
var endTheGame = 9007199254740992,
startTheGame = endTheGame - 100,
count = 0,
index,
result;
for ( index = startTheGame; index count++;
}
result = count;
The following code could make crash your browser!! Be careful!!
var endTheGame = 9007199254740992,
startTheGame = endTheGame - 100,
count = 0,
index,
result;
for ( index = startTheGame; index count++;
}
result = count;
This challenge is listed under
Development & Implementations
Community
Related Posts:
Please login to reply this post
Important:
- We hope the conversations that take place on MyTechLogy.com will be constructive and thought-provoking.
- To ensure the quality of the discussion, our moderators may review/edit the comments for clarity and relevance.
- Comments that are promotional, mean-spirited, or off-topic may be deleted per the moderators' judgment.
1 Suggestion
9007199254740992 is the maximum number that Javascript can handle then it is unable to manage due to the overflow issue, then the most easy way to do it is decrement the number in one to allow Javascript to work with it as shown below.
var endTheGame = 9007199254740991,
startTheGame = endTheGame - 100,
count = 0,
result,
index;
for ( index = startTheGame; index <= endTheGame; index++ ) {
count++;
}
result = count;