29 lines
876 B
HTML
Executable file
29 lines
876 B
HTML
Executable file
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
let text = prompt("Introduce un texto","Este texto es de pruebaaa");
|
|
let char = prompt("Introduce un caracter","a");
|
|
|
|
let count_char = 0;
|
|
for (let i = 0; i < text.length; i++){
|
|
if (text.charAt(i) == char){
|
|
count_char ++;
|
|
}
|
|
}
|
|
console.log(count_char);
|
|
if (count_char >= 2 && count_char <= 4 ){
|
|
alert("El caracter aparece entre 2 y 4 veces en el texto");
|
|
} else {
|
|
alert("El caracter no aparece entre 2 y 4 veces en el texto");
|
|
}
|
|
|
|
</script>
|
|
</body>
|
|
</html> |