cours 1
This commit is contained in:
parent
ecab6410f4
commit
0c2b17b460
83
cours_vanilla_js/script.js
Normal file
83
cours_vanilla_js/script.js
Normal file
@ -0,0 +1,83 @@
|
||||
// variable
|
||||
|
||||
// nombre
|
||||
let a = 2;
|
||||
let b = 5;
|
||||
let x = 2;
|
||||
|
||||
// y = ax + b;
|
||||
|
||||
console.log(a*x+b);
|
||||
|
||||
// chaine de charactère
|
||||
let montext = "texte, ou plutot une chaine de charactères.";
|
||||
let unautretext = "Ha bon :/";
|
||||
// concatenation
|
||||
console.log(montext + unautretext + a*b);
|
||||
|
||||
// Tableau
|
||||
let maliste = [2,4,7,8,9,'un text','ouaa'];
|
||||
console.log(maliste);
|
||||
console.log(maliste[2]);
|
||||
console.log(maliste[5]);
|
||||
|
||||
// imbriqué / nested
|
||||
let mapoupeerusse = [
|
||||
3,
|
||||
"machin",
|
||||
[
|
||||
6,8, 'hoho'
|
||||
]
|
||||
];
|
||||
console.log(mapoupeerusse);
|
||||
|
||||
|
||||
// objet / object
|
||||
let unobjet = {clef1:'valeur', clef2:"valeur2"};
|
||||
|
||||
let listeetudiantes = {
|
||||
rouen: [
|
||||
{
|
||||
nom: 'machin',
|
||||
prenom: 'truc'
|
||||
},
|
||||
{
|
||||
nom: "...",
|
||||
prenom: "..."
|
||||
}
|
||||
],
|
||||
lehavre: [
|
||||
{
|
||||
nom: 'mohamed',
|
||||
prenom: 'eli'
|
||||
},
|
||||
{
|
||||
nom: "...",
|
||||
prenom: "..."
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
console.log(listeetudiantes);
|
||||
|
||||
|
||||
// boucles
|
||||
|
||||
// Object.keys(listeetudiantes) permet de recupérer le tableau des clefs de l'object listeetudiantes
|
||||
|
||||
[7,2,89,4].forEach(value => {
|
||||
|
||||
})
|
||||
|
||||
let listedeskey = Object.keys(listeetudiantes);
|
||||
console.log(listedeskey);
|
||||
listedeskey.forEach(key => {
|
||||
console.log(key);
|
||||
let ville = listeetudiantes[key]
|
||||
console.log(ville);
|
||||
ville.forEach(etudiant => {
|
||||
console.log(etudiant.prenom);
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user