Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

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

Packages

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.

Behavior

Auto Save

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.

HTML

              
                <header>
    <nav>
        <span><a href="#">Les chaînes de caractères</a></span>
        
    </nav>
</header>
<main>
    <div class="container">
            <p id="p1" ></p>
            <p id="p2"></p>
            <p id="p3"></p>
            <p id="p4"></p>
            <p id="p5"></p><br/>
            <p class="titleEx">== Obtenir la longueur de la variable "alpha" ==</p>
            <p id="ex2"></p>
            <p class="titleEx">== Retirer les espaces de la variable "alpha" et de la variable "pharse 3" ==</p>
            <p id="ex3"></p>
            <p class="titleEx">== Obtenir la longueur de la variable "alpha" et de la variable "pharse 2" ==</p>
            <p id="ex4"></p>
            <p class="titleEx">== Trouver le caractère se trouvant à la 6ème position de la variable "pharse 1" ==</p>
            <p id="ex5"></p>
            <p class="titleEx">== Trouver le caractère se trouvant à la 15ème position de la variable "pharse 2" ==</p>
            <p id="ex6"></p>
            <p class="titleEx">== Trouver le caractère se trouvant à la 1ère position de la variable "pharse 1" ==</p>
            <p id="ex7"></p>
            <p class="titleEx">== Trouver le caractère se trouvant à la 25ème position de la variable "alpha" ==</p>
            <p id="ex8"></p>
            <p class="titleEx">== Obtenir "ANANAS" au lieu de "ANANA" ==</p>
            <p id="ex9"></p>
            <p class="titleEx">== La variable alpha se termine-t-elle par A ? ==</p>
            <p id="ex10"></p>
            <p class="titleEx">== La variable "mot" est-elle présente dans la variable "pharse 1" ==</p>
            <p id="ex11"></p>
            <p class="titleEx">== Afficher 10 fois la variable "pharse 3" ==</p>
            <p id="ex12"></p>
            <p class="titleEx">== Remplcer "reine" par "princesse" dans la variable "phrase 2" ==</p>
            <p id="ex13"></p>
            <p class="titleEx">== La variable "phrase 1" contient-elle un caractère spécial ? ==</p>
            <p id="ex14"></p>
            <p class="titleEx">== Diviser la variable "phrase 1" à la vrigule ==</p>
            <p id="ex15"></p>
            <p class="titleEx">== Trouver la sous-chaîne de caractère entre la position 1 et 3 dans la variable "pharse 3" ==</p>
            <p id="ex16"></p>
            <p class="titleEx">== Mettre le texte de la variable "phrase 3" en minuscule ==</p>
            <p id="ex17"></p>
    </div>
    <script src="stringJS.js"></script>

</main>
              
            
!

CSS

              
                /* ===================================
		General
==================================== */
* {
	box-sizing: border-box;
  font-family: 'Open Sans', sans-serif;
}

body {
	margin: 0;
  background-color: #ffffff;
  background-image: url(https://www.transparenttextures.com/patterns/pinstripe-dark.png);
}

a {
	text-decoration: none;
}

p,
ul li,
ol li {
	font-size: 18px;
}

h1, h2, h3, h4, h5, h6 { 
  font-family: 'Russo One', sans-serif;
}



/* ===================================
		Navigation bar
==================================== */
nav {
	background-color: rgb(0, 0, 0);
	display: flex;
	flex-flow: row nowrap;
	height: 100px;
  top: 0;
  position: fixed;
	width: 100%;
  border-bottom: 5px solid rgb(62, 172, 209);
}

nav span {
	color: #ffffff;
	height: 100%;
	font-size: 20px;
	line-height: 100px;
	padding-left: 40px;
	width: 100%;
}

nav ul {
	align-items: center;
	display: flex;
	flex-flow: row nowrap;
	height: 100%;
	justify-content: space-around;
	margin: 0;
	padding: 0;
	width: 40%;
}

nav ul a {
	height: 100%;
	line-height: 100px;
    width: 50%;
    
}

nav ul a:hover li {
	background-color: #f2f2f2;
    color: #8c8c8c;
}

.currentPage {
	background-color: #f2f2f2;
	color: #8c8c8c;
}

nav ul li {
	color: rgb(255, 255, 255);
	font-size: 20px;
	list-style: none;
	text-align: center;
}
nav span a {
	color: #ffffff;
}


/* ===================================
		Main
==================================== */
main {
  margin-top: 130px;
}

.container {
	margin: 0 auto;
	width: 60%;
}

.titleEx {
  font-size: 23px;
	text-align: center;
	color: #54a0ff;
}

h2 {
  font-size: 2.5em;
}

p {
  line-height: 29px;
}

.contact {
	display: flex;
	justify-content: center;
	margin: 0 auto;
	width: 60%;
}

fieldset{
	display: block;
	margin: 1.0em auto;
	text-align: center;
}

.age {
	margin-top: -1px;
  vertical-align: middle;
}

form {
	display: block;
	margin: 1.0em auto;
	text-align: center;
}

textarea {
	width: 600px;
}

input{
	margin-right: 10px;
}

div form p {
	font-size: 35px;
}

/* ===================================
		Image container
==================================== */
.image-container {
	display: flex;
	flex-flow: row no-wrap;
	justify-content: space-around;
}

img {
  border-radius: 10%;
	height: 100%;
	margin: 5px;
	width: 50%;
}

p a {
	color: #54a0ff;
	transition-duration: .1s;
}

p a:hover {
	background-color: #54a0ff;
	color: #fff;
	font-style: italic;
	padding: 5px;
}


/* ===================================
		Footer
==================================== */
footer {
  background-color: #f2f2f2;
}

.important {
	padding: 50px;
	text-align: center;
	width: 100%;
}

h3 {
	color: #f8a5c2;
	font-size: 40px;
	margin: 0;
}

.buttons {
	margin: 0 auto;
	width: 60%;
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	align-content: space-between;
}

button {
	background-color: rgba(255, 255, 0, 0.7);
	font-size: 18px;
	padding: 20px;
	transition-duration: .1s;
	width: 400px;
	margin-left: 100px;
	margin-bottom: 20px;
}
button:hover{
	background-color: rgba(255, 255, 0, 1);
}

#clik {
	background-color: #f8a5c2;
	border: none;
	box-shadow: 2px 2px 5px #000;
	font-size: 18px;
	padding: 20px;
	transition-duration: .1s;
}

button:active {
	transform: scale(.98);
}

ol li {
	font-size: 23px;
}
              
            
!

JS

              
                var phrase_1 = "Joe Biden, est le président de USA.";
var phrase_2 = "la reine des neiges ";
var phrase_3 = " ANANA ";
var alpha = " ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var mot = "USA ";

document.getElementById("p1").innerHTML = "Voici la pharse 1 de départ : " + phrase_1;
document.getElementById("p2").innerHTML = "Voici la pharse 2 de départ : " + phrase_2;
document.getElementById("p3").innerHTML = "Voici la pharse 3 de départ : " + phrase_3;
document.getElementById("p4").innerHTML = "Voici la variable 'Alpha' de départ : " + alpha;
document.getElementById("p5").innerHTML = "Voici le mot de départ : " + mot;

//ex1
var sphrase_1 = phrase_1;
var sphrase_2 = phrase_2;
var sphrase_3 = phrase_3;
var salpha = alpha;
var smot = mot;


//ex2
var alphaLenght = "La longueur de la variable alpha est de " + alpha.length + " caractères";
document.getElementById("ex2").innerHTML = alphaLenght;

//ex3
var trimP3 = phrase_3.trim();
var trimAlpha = alpha.trim();
var resultEx3 = trimP3 + "<br>" + trimAlpha;
document.getElementById("ex3").innerHTML = resultEx3;

//ex4
var p2Lenght = "La longueur de la variable phrase 2 est : " + phrase_2.length + " caractères";
var alphaLenghtBis = "La longueur de la variable alpha est : " + trimAlpha.length + " caractères";
var resultEx4 = "La longueur de la variable phrase 2 est : " + phrase_2.length + " caractères" + "<br>" + "La longueur de la variable alpha est : " + trimAlpha.length + " caractères";
document.getElementById("ex4").innerHTML = resultEx4;

//ex5
var searchLetter = (phrase_1.replace(/ /g,'')).charAt(6);
var resultEx5 = "Le 6ème caractère est : " + searchLetter;
document.getElementById("ex5").innerHTML = resultEx5;

//ex6
var searchLetter1 = (phrase_2.replace(/ /g,'')).charAt(15);
var resultEx6 = "Le 15ème caractère est : " + searchLetter1;
document.getElementById("ex6").innerHTML = resultEx6;

//ex7
var searchLetter2 = (phrase_1.replace(/ /g,'')).charAt(1);
var resultEx7 = "Le 1er caractère est : " + searchLetter2;
document.getElementById("ex7").innerHTML = resultEx7;

//ex8
var searchLetter3 = (alpha.replace(/ /g,'')).charAt(25);
var resultEx8 = "Le 25ème caractère est : " + searchLetter3;
document.getElementById("ex8").innerHTML = resultEx8;

//ex9
var addS = phrase_3.trim() + "S";
var resultEx9 = addS;
document.getElementById("ex9").innerHTML = resultEx9;

//ex10
var findA = phrase_3.lastIndexOf("A");
if (findA != -1) {
    document.getElementById("ex10").innerHTML = "Il y a un A à la fin de la pharse 3";
} else {
    document.getElementById("ex10").innerHTML = "Il n'y a pas de A à la fin de la phrase 3";
}

//ex11
var findWord = phrase_1.search(mot);
if (findA != -1) {
    document.getElementById("ex11").innerHTML = "La pharse 1 contient " + mot;
} else {
    document.getElementById("ex11").innerHTML = "La pharse 1 ne contient pas " + mot;
}

//ex12
document.getElementById("ex12").innerHTML = phrase_3.repeat(10);

//ex13
replaceWord = phrase_2.replace("reine", "princesse");
document.getElementById("ex13").innerHTML = replaceWord;

//ex14
var splChars = "*|,\":<>[]{}`\';()@&$#%";
if (phrase_1.indexOf(splChars) == -1) {
    document.getElementById("ex14").innerHTML = "Il y a des caractères spéciaux";
} else {
    document.getElementById("ex14").innerHTML = "Il n'y a pas de caractères spéciaux";
}

//ex15
var split = phrase_1.split(",");
console.log(split);
document.getElementById("ex15").innerHTML = split;

//ex16
var trimP3ex16 = phrase_3.trim();
var searchLetterAnana = trimP3ex16.substring(1, 3);
document.getElementById("ex16").innerHTML = searchLetterAnana;

//ex17
var lowerCase = mot.toLowerCase();
document.getElementById("ex17").innerHTML = lowerCase;

              
            
!
999px

Console