Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, My program isn\'t displaying the results. It should print all numbers ent

ID: 3712231 • Letter: H

Question

Hello,

My program isn't displaying the results. It should print all numbers entered that arent a duplicate and meet requirements of program.

comments and output appreciated

<!DOCTYPE html>

<html lang=en>

<head>

<meta charset="utf-8">

<title>Part 4</title>

</head>

<body>

Enter Number: <input type="text" id="input" value="">

<button>Submit</button>

<script>

function numEnter() {

document.getElementById("input").value = "";

}

</script>

<script>

var input = [];

var output = [];

for(var i = 0; i= 10 && input[i] <= 100 && !output.includes(input[i])) {

output.push(input[i]);

console.log(input[i]);

}}

else { console.log("Invalid number: " + input[i]);

}}

  

  

  

</script>

</body>

</html>

Thank you

Explanation / Answer

<!DOCTYPE html>

<html lang=en>

<head>

<meta charset="utf-8">

<title>Part 4</title>

</head>

<body>

Enter Number: <input type="text" id="input" value="">

<button>Submit</button>


<script>
   var input = [];
   var output = [];

function numEnter() {
     var enteredValue = parseInt(document.getElementById("input").value);
  
     if (isNaN(enteredValue)) {
     document.getElementById("input").value = "";
    console.log("Invalid number: " + enteredValue);
}
else{

   input.push(enteredValue);

     for (var i=0; i<input.length; i++)
         {
             // Check if the picked element is already printed
             var j;
             for (j=0; j<i; j++){
                if (input[i] == input[j])
                    break;
              }
             // If not printed earlier, then print it
             if (i == j)
               console.log(input[i]);
         }

    document.getElementById("input").value = "";
  
  
}
}

</script>


</body>

</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote