4838 Shares

# JavaScript Code Help?

Topic: What is a problem solving loop
July 18, 2019 / By Mace
Question: So I am on a site that teaches you things you need to know about certain things, and they have different puzzles for you to solve. Here is the code. http://pastebin.com/Cx78PSqk When I enter this puzzle, a box pops up saying "Sorry, did you fail already?!" I do not quite understand the code. Can someone tell me what I am supposed to do? @Brave It's not a trick, the code is for getting it to allow me to advance to the next one. This one is under Date Manipulation. Not exactly sure what I am supposed to change here. @Chris Since this is under Date Manipulation, I figured I had to change the date.. Other than that, I don't know what else to do. I cannot edit anything on here, so I am assuming not. Also, I am assuming that because when I first go to that, the error pops up, so I figured I need to do the equation to get the right year that I need to go to.

## Best Answers: JavaScript Code Help?

Jehiel | 7 days ago
The other guy is obviously clueless. What the code does is get the current year, then adds it to pass, a lot. This line: pass += year * i * year; says, calculate year*year, multiply that by i, then add the result to the current value of pass. This line is executed multiple times, with i being 1 the first time, then 2, then 3, etc. until it is equal to year. I did a test run, and the first problem is: year isn't 2013 but 113, because Date().getYear() returns the years since 1900. Using 113, the result of the loop was 82246466. When I add 1900 so the year is 2013, then pass ends up being 8214115311716. Not sure where the other number is coming from. This will work: http://pastebin.com/1ck9sFPu The thing is, what are you expected to do here? Are you supposed to edit the contents of the loop?
👍 182 | 👎 7
Did you like the answer? JavaScript Code Help? Share with your friends

We found more questions related to the topic: What is a problem solving loop

Originally Answered: What is worng with this JavaScript code?
Ok, first up:
Originally Answered: What is worng with this JavaScript code?
Use commonly used rates, no longer those fancy looking ones. additionally, that e book could be tremendously previous. you do no longer could hid your JavaScript code anymore. you will no longer detect a private laptop information superhighway browser that would not help JavaScript at the instant. Write your HTML tags in lowercase, comparable with your attributes. you could unload the two the language and form attributes for the script tag. The language characteristic isn't used anymore and the default form for the script tag is text fabric/javascript besides so there is not any evaluate writing that the two.

Garth
I think it's a trick lol because a box just popping up without you typing anything. Most sites like messing with ur brain!
👍 70 | 👎 6

Devil
It sets the value of pass..... pass = 1337; It perfroms a calculation with pass and year... pass += year * i * year; And then test the value in pass... if(pass == 318338237039211050000) { alert("Good job!"); window.location.href = year + ".php"; } else { alert("Sorry, did you fail already?!"); window.location.href = "./index.php"; } If the calculation is not equal to 318338237039211050000 you are seeing the "fail" message.
👍 64 | 👎 5

Originally Answered: Is that OK if javascript code is in the middle of the page, not on top?
You can put javascript code anywhere in php file, provided you are embedding that code in tag. You can also write javascript code using php syntax. I mean inside tag with echo.

If you have your own answer to the question what is a problem solving loop, then you can write your own version, using the form below for an extended answer.