Hello every Body. I have creat a little script for test something.
I search a solution regarding the inclusion a Js file.
javascript:
const btn = document.querySelector(“ion-button”);
const fruits = [“banane”, “cerise”, “orange”, “raisin”, “ananas”];
const result = document.querySelector(".result");
function random(){
let fruit_random = Math.round(Math.random()*(fruits.length-1));
console.log(fruits[fruit_random])
result.innerHTML = fruits[fruit_random]
}
btn.addEventListener(“click”, random);
html:
html:
Fruit aléatoire
Salut
résultat
4 posts - 2 participants