Diferència entre revisions de la pàgina «M06 UF1Q5. Exercicis per practicar objectes»
Salta a la navegació
Salta a la cerca
m |
m |
||
| Línia 1: | Línia 1: | ||
=Introducció= | =Introducció= | ||
A classe hem estat veient la teoria d'expressions regulars: | A classe hem estat veient la teoria d'expressions regulars: | ||
| − | *=Desenvolupament= | + | *https://developer.mozilla.org/es/docs/Web/JavaScript/Guide/Working_with_Objects |
| + | |||
| + | =Desenvolupament= | ||
=Tasques a realitzar= | =Tasques a realitzar= | ||
| − | 1. | + | 0. Crea l'objecte '''Assignatura''': |
| + | <pre> | ||
| + | var Asignatura = { | ||
| + | ref: 'BBDD', | ||
| + | nom: 'Bases de Dades', | ||
| + | hores: 180, | ||
| + | UF: ['UF1','UF2','UF3','UF4'], | ||
| + | professor: 'Pep Parés', | ||
| + | alumnes: ['alu1','alu2','alu13,'alu4','alu5'] | ||
| + | }; | ||
| + | </pre> | ||
| + | |||
| + | 1. Write a JavaScript program to list the properties of a JavaScript object. | ||
| + | |||
| + | 2. Write a JavaScript program to delete the rollno property from the following object. Also print the object before or after deleting the property. | ||
| + | |||
| + | 3. Write a JavaScript program to get the length of a JavaScript object. | ||
| + | |||
| + | 4. Write a JavaScript program to display the reading status (i.e. display book name, author name and reading status) of the following books. | ||
| + | <pre> | ||
| + | var library = [ | ||
| + | { | ||
| + | author: 'Bill Gates', | ||
| + | title: 'The Road Ahead', | ||
| + | readingStatus: true | ||
| + | }, | ||
| + | { | ||
| + | author: 'Steve Jobs', | ||
| + | title: 'Walter Isaacson', | ||
| + | readingStatus: true | ||
| + | }, | ||
| + | { | ||
| + | author: 'Suzanne Collins', | ||
| + | title: 'Mockingjay: The Final Book of The Hunger Games', | ||
| + | readingStatus: false | ||
| + | }]; | ||
| + | </pre> | ||
| + | 5. | ||
| + | |||
| + | 6. | ||
| + | |||
| + | 7. | ||
| + | |||
| + | 8. | ||
| + | |||
| + | 9. | ||
| − | + | 10. | |
Revisió del 10:39, 28 oct 2021
Introducció
A classe hem estat veient la teoria d'expressions regulars:
Desenvolupament
Tasques a realitzar
0. Crea l'objecte Assignatura:
var Asignatura = {
ref: 'BBDD',
nom: 'Bases de Dades',
hores: 180,
UF: ['UF1','UF2','UF3','UF4'],
professor: 'Pep Parés',
alumnes: ['alu1','alu2','alu13,'alu4','alu5']
};
1. Write a JavaScript program to list the properties of a JavaScript object.
2. Write a JavaScript program to delete the rollno property from the following object. Also print the object before or after deleting the property.
3. Write a JavaScript program to get the length of a JavaScript object.
4. Write a JavaScript program to display the reading status (i.e. display book name, author name and reading status) of the following books.
var library = [
{
author: 'Bill Gates',
title: 'The Road Ahead',
readingStatus: true
},
{
author: 'Steve Jobs',
title: 'Walter Isaacson',
readingStatus: true
},
{
author: 'Suzanne Collins',
title: 'Mockingjay: The Final Book of The Hunger Games',
readingStatus: false
}];
5.
6.
7.
8.
9.
10.
Entrega
Entrega al Classroom, en format pdf o google docs, dels codis generats i les sortides per pantalla que demostrin el bon funcionament dels exercicis.
Ajuda
creat per Joan Quintana Compte, octubre 2021