Skip to content

Commit 7796f22

Browse files
committed
[WIP] Clase guiada - Libro JS
1 parent da9f9d9 commit 7796f22

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

clase_12/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<html lang="en">
2+
<head>
3+
<meta charset="UTF-8">
4+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<script src="script.js"></script>
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
11+
12+
</body>
13+
</html>

clase_12/script.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
class Libro{
2+
constructor(title, author, year, genre){
3+
this.title = title;
4+
this.author = author;
5+
this.year = year;
6+
this.genre = genre;
7+
}
8+
9+
infoLibro(){
10+
return `Título: ${this.title}, Author: ${this.author}, Year: ${this.year}, Genre: ${this.genre}.`;
11+
}
12+
}
13+
14+
let books = []
15+
let title, author, year, genre;
16+
while (books.length<3){
17+
18+
title = prompt('Ingrese el título: ');
19+
author = prompt('Ingrese el autor: ');
20+
year = prompt('Ingrese el año: ');
21+
genre = prompt('Ingrese el género: ').toLowerCase();
22+
23+
if(title !='' &&
24+
author!=''&&
25+
!isNaN(year)&&
26+
year.length==4 &&
27+
(genre =='aventura' || genre == 'terror' || genre == 'fantasia')){
28+
books.push(new Libro(title,author,year,genre));
29+
}
30+
31+
set
32+
33+
}
34+
// const l1 = new Libro();
35+
// const l2 = new Libro();
36+
// const l3 = new Libro();

0 commit comments

Comments
 (0)