IFCD0210/Practicas/Practicas JS/Practica 4/index.html
Marcos Lopez f86dee8067 Dia 28
2024-01-16 13:46:24 +01:00

59 lines
1.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="./js/main.js"></script>
<title>Ejercicio 3</title>
</head>
<body>
<script>document.write(texto1)</script>
<br>
<script>document.write(texto2)</script>
<br>
<br>
<script>
//document.write(`Numero de caracteres 'u' en texto1: ${texto1.split('u').length-1}`) - falla cuando la ultima letra es la que buscas, habria que controlarlo
let contador = 0;
for (let i = 0; i < texto1.length; i++) {
if (texto1.charAt(i) === 'u') {
contador++;
}
}
document.write(`Numero de caracteres 'u' en texto1: ${contador}`);
</script>
<br>
<script>document.write(`Numero de caracteres texto2: ${texto2.length}`)</script>
<br>
<script>document.write(`Caracteres siete de texto2: ${texto2[6]}`)</script>
<br>
<script>
texto3 = `${texto1} ${texto2}`;
document.write(`Union de cadenas: ${texto3}`);
</script>
<br>
<script>
texto4 = texto2.concat(` y pelicula de los viernes`)
document.write(texto4)
</script>
<br>
<script>
document.write(texto1.indexOf('un', texto1.indexOf('Mancha') + 5))
</script>
<br>
<script>
document.write(texto1.lastIndexOf('de'))
</script>
<br>
<script>
document.write(texto2.split(' '));
</script>
<br>
<script>
document.write(texto2.replace(/\s/g, "<br>"));
</script>
</body>
</html>