Hi there, I'm looking for some guidance as a beginner in JavaScript for a school project. Below are the specifications of the software: The software will translate into French or German integer numbers from 1 to 30 inclusive. The program should ask: 1) What number to translate • The user should type digits • If the user doesn’t type digits, the following message must be displayed “Please use digits” and the program must end • If the user doesn’t type a number between 1 and 30, the following message must be displayed “Please type an integer number between 1 and 30” and the program must end 2) What is the output language • The user should type German or French (case is insensitive) • If the user doesn’t type German or French, the following message must be displayed “only French or German is allowed” and the program must end 3) Display the result in the following syntax: “The translation is XXX” 4) Wait for any key to exit As shown above, it is going to be a console based program, there won’t be any graphical user interface. T.I.A Chris.
First up, thanks for letting us know that this is a school project. We'll point you in the right direction, check your work but we won't do it for you because that defeats the purpose. Secondly, good to have some Kiwi company on here. Third, get an online place to test and share your code, jsfiddle is good, I like codepen too. When the user types there are two ways to catch what they've typed. <input type="text" onkeyup="myFunction()"> but that sucks and I'd mark you down for using it. That said, I'm not your teacher. document.getElementById('digit').addEventListener('keyup', logKey); listeners are the right way to catch the keystroke and call a javascript function - or use an anonymous function As for the translation, I guess you just have an array for German and another for French and use the input number as the key to the array.