Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.






                //-----CODE NON DRY------

//variable de différentes personnes
let personne1 = "Jean";
let personne2 = "Paul";
let personne3 = "Marcel";

function saluer(prenom){
  //On met la première lettre en majuscule, on salue la personne et on donne le nombre de lettre dans son prénom
  const monPrenom = prenom[0].toUpperCase() + prenom.substr(1);
  const longueurPrenom = monPrenom.length;
  console.log(`Bonjour ${monPrenom}, ton prénom contient ${longueurPrenom} lettres`);

//On salue les 3 personnes

//-----CODE MAL NOMMÉ------

//tableau des ages des élèves dans la classe
const agesElevesDeClasse = [14, 14, 15, 14, 16, 14, 14, 13];
// Nombre d'élèves
const nombreEleves = agesElevesDeClasse.length;
// variable pour calculer la somme des ages
let sommeAges = 0;
for(let age of agesElevesDeClasse){
  sommeAges += age;
//moyenne d'age dans la classe
const moyenneAgesDeClasse = sommeAges / nombreEleves;
console.log('Il y a ' + nombreEleves + " élèves dans la classe et la moyenne d'age est " + moyenneAgesDeClasse);

//-----CODE MAL MIS EN FORME------

const temperature = 25;

if(temperature < 10){
  console.log("Il fait très froid"); }
else if(temperature < 0){
  console.log("Il fait froid");
}else if(temperature < 10){
  console.log("Il fait frais");
}else if(temperature < 20){
  console.log("Il fait doux");
}else if(temperature < 30){
  console.log("Il fait bon");
  console.log("Il fait chaud");