This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Chien = { | |
init: function (nom, race, taille) { | |
this.nom = nom; | |
this.race = race; | |
this.taille = taille; | |
}, | |
aboyer: function () { | |
var description = " Grrr! Grrr! "; | |
return description; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Film = { | |
// Initialise le film | |
init: function (titre, annee) { | |
this.titre = titre; | |
this.annee = annee; | |
}, | |
// Renvoie la description du film | |
decrire: function () { | |
var description = this.titre + " (" + this.annee + ")"; | |
return description; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* La fenêtre de saisie se charge en 1er et n'affiche | |
pas le console.log tant qu'elle n'est pas validée. | |
Comment afficher les 2 simultanément ? */ | |
console.log('merci de répondre à ce questionnaire'); | |
var plat = prompt("Quel est votre plat préféré ?"); | |
switch(plat) // debut du switch | |
{ | |
case "frites": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Activité : gestion des contacts | |
*/ | |
// TODO : complétez le programme | |
var Contact = { | |
// initialisation du contact | |
init: function (nom, prenom) { | |
this.prenom = prenom; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// affiche “Vrai” si la chaîne compte autant de “x” que de “o”. | |
var chaine = "xoxxooxoxxxoooo"; | |
var x = 0; | |
var o = 0; | |
for (var i = 0; i < chaine.length; i++) { | |
if (chaine[i] === "x") { | |
x++; | |
} else if (chaine[i] === "o") { | |
o++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | |
background-color: #eee; | |
margin-left: 30px; | |
margin-right: 30px; | |
} | |
span { | |
font-weight: normal; | |
font-size: 80%; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Changer la couleur des divs : | |
*/ | |
document.addEventListener("keypress", function (e) { | |
var touche = String.fromCharCode(e.charCode); // Récupération de la touche pressée | |
touche = touche.toUpperCase(); // Pour gérer indifféremment minuscules et majuscules | |
var couleur = ""; | |
switch (touche) { | |
case "B": |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Exercice : compter les clics | |
*/ | |
function clic() { | |
compteurClics++; | |
document.getElementById("compteurClics").textContent = compteurClics; | |
} | |
var compteurClics = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clic() { | |
console.log("Clic !"); | |
} | |
var boutonElt = document.getElementById("bouton"); | |
// Ajout d'un gestionnaire pour l'évènement click | |
boutonElt.addEventListener("click", clic); | |
/*var boutonElt = document.getElementById("bouton"); | |
// Ajout d'un gestionnaire pour l'évènement click |