Asked by Anonymous
How do I count how many arrays there is - what do I add to the code? I have managed to create 2 buttons and the top button works and changes the fruits into alphabetical order but the second button doesn't work - please help!
<!DOCTYPE html>
<html>
<body>
<h4>Press the button to change the fruits into alphabetical orders.</h4>
<button onclick="myFunction()">Click here to arrange the fruits into alphabetical order</button>
<p id="demo"></p>
<h4>Press the second button to find out how many array's there is.</h4>
<button onclick="myFunction1()">Click here to see there number of arrays.</button>
<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;
function myFunction() {
fruits.sort();
document.getElementById("demo").innerHTML = fruits;
}
</script>
</body>
</html>
Many thanks
<!DOCTYPE html>
<html>
<body>
<h4>Press the button to change the fruits into alphabetical orders.</h4>
<button onclick="myFunction()">Click here to arrange the fruits into alphabetical order</button>
<p id="demo"></p>
<h4>Press the second button to find out how many array's there is.</h4>
<button onclick="myFunction1()">Click here to see there number of arrays.</button>
<script>
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;
function myFunction() {
fruits.sort();
document.getElementById("demo").innerHTML = fruits;
}
</script>
</body>
</html>
Many thanks
Answers
There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.