@@ -199,6 +199,8 @@ class Fraction {
199199 if ( this . constructor . SYMBOL ) {
200200 if ( this . numerator === - 1 ) {
201201 result += "-" ;
202+ } else if ( this . numerator !== 1 ) {
203+ result += this . numerator ;
202204 }
203205 } else {
204206 result += this . numerator ;
@@ -343,11 +345,10 @@ function generateQuestion() {
343345
344346const questionContainer = document . getElementById ( "question-container" ) ;
345347
346- let answer ;
348+ let question ;
347349function displayNewQuestion ( ) {
348- const q = generateQuestion ( ) ;
349- document . getElementById ( "question" ) . textContent = q . question ;
350- answer = q . answer ;
350+ question = generateQuestion ( ) ;
351+ document . getElementById ( "question" ) . textContent = question . question ;
351352 document . getElementById ( "result" ) . style . display = "none" ;
352353 const input = document . getElementById ( "question-input" ) ;
353354 input . value = "" ;
@@ -373,14 +374,14 @@ document.getElementById("question-input").addEventListener("input", function() {
373374
374375document . getElementById ( "show-answer" ) . addEventListener ( "click" , function ( ) {
375376 const input = document . getElementById ( "question-input" ) ;
376- input . value = answer ;
377+ input . value = question . answer ;
377378} ) ;
378379
379380document . getElementById ( "trig-form" ) . addEventListener ( "submit" , function ( event ) {
380381 event . preventDefault ( ) ;
381382 const input = document . getElementById ( "question-input" ) ;
382383 const resultDiv = document . getElementById ( "result" ) ;
383- if ( input . value . trim ( ) . replace ( / p i / g, "π" ) . replace ( / s q r t / g, "√" ) === answer ) {
384+ if ( input . value . trim ( ) . replace ( / p i / g, "π" ) . replace ( / s q r t / g, "√" ) === question . answer ) {
384385 resultDiv . innerHTML = "Bonne réponse !" ;
385386 resultDiv . className = "result correct" ;
386387 setTimeout ( displayNewQuestion , 2000 ) ; // Display a new question after 2 seconds
0 commit comments