I need to convert the following code to javascript.
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;
}

