I need help converting C++ to Javascript. Here is the original code: Code: #include <iostream> int main () { // Variables short first; short second; short previous; short current; short help; // Input and communication with the user cout << "Insert the first digit: "; cin >> first; cout << "\n"; cout << "Insert the second digit: "; cin >> second; cout << "\n"; cout << "The necklace is: "; // Preparing for the loop previous = second; current = (first + second)%10; cout >> first; cout >> second; // And not the WHILE loop while ( (previous != first) || (current != second) ) { cout >> current; help = previous; previous = current; current = (help + current)%10; } // Writing the last digit cout >> current; return 0; } Here is my JS Code: Code: <SCRIPT = "text/javascript"> // Quickstart C++ to JS First = prompt("Enter a digit: "); Second = prompt("Enter a second digit: "); //Convert FirstNum = parseInt(First); SecondNum = parseInt(Second); //prepare for loop previousnum = secondnum; currentnum = (FirstNum + SecondNum)%10; //loop do{ extra = previousnum; previousnum = currentnum; currentnum = (extra + currentnum)%10; } while (previousnum !=Firstnum || currentnum != SecondNum) //Output document.writeln("first number "+First+"<br>"); document.writeln("second number "+Second+"<br>"); document.writeln("Necklace is "+currentnum); </SCRIPT> How well did I do? It won't load in my browser, so I need someone to run it for me and tell me if I did okay, and how to fix it if I didn't.
You can't (or shouldn't want to) convert that C++. It isn't functional. If that's the original code, it never compiled.