jda_m06/uf01/exercicis_uf01_02/exercic_11.html
2022-02-16 16:13:08 +01:00

43 lines
756 B
HTML
Executable file

<!DOCTYPE html>
<html>
<body>
<h2>Exercicis JavaScript UF01 2</h2>
<h3>Jan Maroto</h3>
<h4 id="demo"></h4>
<script>
fname = prompt("Introdueïx el teu nom");
mname = prompt("Introdueïx el teu cognom");
lname = prompt("Introdueïx el teu segon cognom");
nCharA = 0;
nCharB = 0;
[...input].forEach(firstFunction);
if (nCharA == nCharB) {
text = "Hi han el mateix nombre de as que de bs";
} else {
text = "No hi han el mateix nombre de as que de bs";
}
function firstFunction(char) {
if (char == 'a') {
++nCharA;
} else if (char == 'b') {
++nCharB;
}
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>