diff --git a/css/styles.css b/css/styles.css new file mode 100644 index 0000000..223d06e --- /dev/null +++ b/css/styles.css @@ -0,0 +1,36 @@ +.button { + font-family: Arial, Helvetica, sans-serif; + font-size: 20px; + font-weight: bold; + color: #fff; + background-color: crimson; + text-align: center; + border-radius: 10px; + width: 150px; + height: 90px; + padding: 20px; + margin: 5px; + float: left; +} + +.result { + font-family: Arial, Helvetica, sans-serif; + font-size: 20px; + font-weight: bold; + color: #fff; + background-color: crimson; + text-align: center; + border-radius: 10px; + width: 200px; + height: 50px; + padding: 20px; + margin: 5px; + float: left; +} + +.contenedor { + width: 100%; + height: 100px; + float: left; + clear: both; +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..3d550cc --- /dev/null +++ b/index.html @@ -0,0 +1,31 @@ + + + + + + + + + + Document + + +
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ + + diff --git a/main.js b/main.js new file mode 100644 index 0000000..a2c229a --- /dev/null +++ b/main.js @@ -0,0 +1,54 @@ +document.getElementById('button1').addEventListener('click', function() { + exercici1(); +}); +document.getElementById('button2').addEventListener('click', function() { + exercici2(); +}); +document.getElementById('button3').addEventListener('click', function() { + exercici3(); +}); +// document.getElementById('button1').addEventListener('click', exercici1()); +// document.getElementById('button2').addEventListener('click', exercici2()); +// document.getElementById('button3').addEventListener('click', exercici3()); + +function exercici1() { + let respuesta = 'jello'.indexOf('e'); + document.getElementById('text1').innerHTML = respuesta; + console.log(respuesta); +} +// Exercici 2 +function exercici2() { + let nombre = prompt('Introduce tu nombre :'); + let apellido = prompt('Introduce tu apellido :'); + // alert(`Hola ${nombre} ${apellido}!`); + document.getElementById('text2').innerHTML = `Hola ${nombre} ${apellido}!`; +} +// Exercici 3 +function exercici3() { + let cadena = prompt('Introduce una cadena de texto :'); + let array = "a b c d f g h i j k l m n ñ o p q r s t u v w x y z A B C D E F G H Y J K L M N Ñ O P Q R S T U V W X Y Z".split(' '); + let muestra = array[Math.floor(Math.random() * array.length)]; + if(cadena.includes(muestra)){ + document.getElementById('text3').innerHTML = `El carácter ${muestra} SÍ está.`; + } else { + document.getElementById('text3').innerHTML = `El carácter ${muestra} NO está.`; + } +} +// Exercici 4 +function exercici4() { + let population = 1000; + let increaseTax = 0.02; + let increaseNum = 50; + let year = 1; + + while (population < 1200) { + population += population * increaseTax + 50; + console.log('population : ' + population + ' year :' + year); + year++; + } + if (year > 2) { + document.getElementById('text3').innerHTML = `Necessita ${year - 1} anys.`; + } else { + document.getElementById('text3').innerHTML = `Necessita ${year - 1} any.`; + } +}