Skip to content

Commit

Permalink
js tuto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
beumsk committed Oct 26, 2023
1 parent 294b0c4 commit 99ab86f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions JS.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@

var a = 10; // shortened method

var a = 0; a += 1; a ++; // add 1 and 1 to 'a' variable to reach 2
var a = 0; a += 1; a++; // add 1 and 1 to 'a' variable to reach 2

var a = 5; a -= 1; a --; // subtracts 1 and 1 to reach 3
var a = 5; a -= 1; a--; // subtracts 1 and 1 to reach 3

var a = 5; a *= 5; a /= 5; // multiply by 5 and divide by 5 to reach 5

Expand Down Expand Up @@ -955,6 +955,11 @@
console.log(str.toUpperCase()); // "KANGAROO"


// capitalize first letter
var str = "kangaroo";
str.charAt(0).toUpperCase() + str.slice(1); // Kangaroo


// string.replace() replace a string in a string
var str = "Salut, c'est chouette !";
console.log(str.replace("chouette", "cool")); // "Salut, c'est cool !"
Expand Down Expand Up @@ -1105,6 +1110,8 @@


// Math.round
Math.round(4.3); // 4
Math.round(4.7); // 5
Math.round(0.6666 * 100) / 100; // 0.67
Math.round(0.66666666 * 10000) / 10000; // 0.6667

Expand Down

0 comments on commit 99ab86f

Please sign in to comment.