File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed
m2-front-end-101/s7-s8-javascript/browser-console Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -26,3 +26,7 @@ Click to see the code in action 👉 [LIVE DEMO](https://armincano.github.io/ful
26
26
- [ Airline - Buy a flight] ( ./m2-front-end-101/s5-s6-bootstrap/airline-promo-and-form/airline-promo-and-form.html )
27
27
- [ Form component] ( ./m2-front-end-101/s5-s6-bootstrap/form/form.html )
28
28
- [ Cards and Navbar components] ( ./m2-front-end-101/s5-s6-bootstrap/navbar-cards/navbar-cards.html )
29
+
30
+ ### JavaScript
31
+
32
+ -[ Compare numbers] ( ./m2-front-end-101/s7-s8-javascript/browser-console/compare-numbers.html )
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=
6
+ , initial-scale=1.0 ">
7
+ < title > Browser console - compare numbers</ title >
8
+ </ head >
9
+ < body >
10
+
11
+ < script src ="./script.js "> </ script >
12
+ </ body >
13
+ </ html >
Original file line number Diff line number Diff line change
1
+ const getUserInput = ( message ) => {
2
+ let userInput ;
3
+ do {
4
+ userInput = prompt ( message ) ;
5
+ if ( userInput === null ) {
6
+ alert ( "Operación cancelada" ) ;
7
+ return null ;
8
+ }
9
+ } while ( isNaN ( parseInt ( userInput ) ) || userInput . trim ( ) === "" ) ; //lo parseado no es un número o está vacío
10
+ return parseInt ( userInput ) ;
11
+ } ;
12
+
13
+ const compareNumbers = ( ) => {
14
+ alert ( "Vamos a comparar qué número es mayor" ) ;
15
+
16
+ const a = getUserInput ( "Introduce el primer número" ) ;
17
+ if ( a === null ) return ;
18
+ const b = getUserInput ( "Introduce el segundo número" ) ;
19
+ if ( b === null ) return ;
20
+
21
+ if ( a === b ) {
22
+ alert ( `${ a } y ${ b } son iguales` ) ;
23
+ } else if ( a > b ) {
24
+ alert ( `${ a } es mayor que ${ b } ` ) ;
25
+ } else {
26
+ alert ( `${ b } es mayor que ${ a } ` ) ;
27
+ }
28
+ } ;
29
+
30
+ compareNumbers ( ) ;
You can’t perform that action at this time.
0 commit comments