1

I'm using Javascript in CodeHS to create a 10-question quiz asking for user input in each question. After about the fourth question, the user must scroll down through the questions to see the next question they'll have to answer. This is very inconvenient and can get annoying.

Here is a picture of having to scroll down to get to the question the user currently is answering. I'm trying to find a way to clear the user input after each question in Javascript CodeHS, so the user will only be able to see the question they're currently answering, without having to scroll down each time.

Here is my code for reference:

/* Asks the user questions and determines if the user's 
    input answers are emo (or correct) or not. */
function quiz(){
    var score = 0;
    for (var i = 0; i < questions.length; i++){
        var answer = readLine(questions[i]);
        if(answer == correct[i]){
            println("Great!");
            score++;
        } else {
            println("That's not very emo of you, next question!");
        }
    }
    

    /*This variable calculates how emo the user is
        based on the number of correct answers. */
    var calculate = score * 100 / questions.length;
    println("You are: " + calculate + "% emo! Congratulations." );
}
Cjmarkham
  • 9,484
  • 5
  • 48
  • 81
Skylar Lim
  • 11
  • 1
  • Instead of deleting, why not have the ui always scroll itself to the bottom? See here https://stackoverflow.com/questions/270612/scroll-to-bottom-of-div. Do it at every turn of the loop. – danh Apr 15 '22 at 16:51

1 Answers1

0

I have done some research and I think its is only possible on Codehs Java and Python.

  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/31912039) – spaleet Jun 04 '22 at 08:20