diff --git a/live-examples/js-examples/bigint/bigint-asintn.js b/live-examples/js-examples/bigint/bigint-asintn.js index 34e99aaf0..93ffea892 100644 --- a/live-examples/js-examples/bigint/bigint-asintn.js +++ b/live-examples/js-examples/bigint/bigint-asintn.js @@ -8,6 +8,5 @@ function check64bit(number) { check64bit(2n ** 64n); // Expected output: "Number doesn't fit in signed 64-bit integer!" - check64bit(2n ** 32n); // Expected output: 4294967296n diff --git a/live-examples/js-examples/intl/intl-listformat-prototype-formattoparts.js b/live-examples/js-examples/intl/intl-listformat-prototype-formattoparts.js index bd147cac5..4bf676ca9 100644 --- a/live-examples/js-examples/intl/intl-listformat-prototype-formattoparts.js +++ b/live-examples/js-examples/intl/intl-listformat-prototype-formattoparts.js @@ -1,8 +1,10 @@ const vehicles = ['Motorcycle', 'Bus', 'Car']; + const formatterEn = new Intl.ListFormat('en', { style: 'long', type: 'conjunction', }); + const formatterFr = new Intl.ListFormat('fr', { style: 'long', type: 'conjunction', diff --git a/live-examples/js-examples/string/string-indexof.js b/live-examples/js-examples/string/string-indexof.js index 24f2c2077..78c3600ba 100644 --- a/live-examples/js-examples/string/string-indexof.js +++ b/live-examples/js-examples/string/string-indexof.js @@ -1,18 +1,15 @@ -const paragraph = - 'The quick brown fox jumps over the lazy dog. If the dog barked, was it really lazy?'; +const paragraph = "I think Ruth's dog is cuter than your dog!"; const searchTerm = 'dog'; const indexOfFirst = paragraph.indexOf(searchTerm); -console.log( - `The index of the first "${searchTerm}" from the beginning is ${indexOfFirst}`, -); -// Expected output: "The index of the first "dog" from the beginning is 40" +console.log(`The index of the first "${searchTerm}" is ${indexOfFirst}`); +// Expected output: "The index of the first "dog" is 7" console.log( - `The index of the 2nd "${searchTerm}" is ${paragraph.indexOf( + `The index of the second "${searchTerm}" is ${paragraph.indexOf( searchTerm, indexOfFirst + 1, )}`, ); -// Expected output: "The index of the 2nd "dog" is 52" +// Expected output: "The index of the second "dog" is 41" diff --git a/live-examples/js-examples/string/string-lastindexof.js b/live-examples/js-examples/string/string-lastindexof.js index b40bea7f8..16e6712e5 100644 --- a/live-examples/js-examples/string/string-lastindexof.js +++ b/live-examples/js-examples/string/string-lastindexof.js @@ -1,11 +1,8 @@ -const paragraph = - 'The quick brown fox jumps over the lazy dog. If the dog barked, was it really lazy?'; +const paragraph = "I think Ruth's dog is cuter than your dog!"; const searchTerm = 'dog'; console.log( - `The index of the first "${searchTerm}" from the end is ${paragraph.lastIndexOf( - searchTerm, - )}`, + `Index of the last ${searchTerm} is ${paragraph.lastIndexOf(searchTerm)}`, ); -// Expected output: "The index of the first "dog" from the end is 52" +// Expected output: "Index of the last "dog" is 38" diff --git a/live-examples/js-examples/string/string-replace.js b/live-examples/js-examples/string/string-replace.js index dc60e0e63..eea5d46bc 100644 --- a/live-examples/js-examples/string/string-replace.js +++ b/live-examples/js-examples/string/string-replace.js @@ -1,9 +1,8 @@ -const p = - 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?'; +const paragraph = "I think Ruth's dog is cuter than your dog!"; -console.log(p.replace('dog', 'monkey')); -// Expected output: "The quick brown fox jumps over the lazy monkey. If the dog reacted, was it really lazy?" +console.log(paragraph.replace("Ruth's", 'my')); +// Expected output: "I think my dog is cuter than your dog!" const regex = /Dog/i; -console.log(p.replace(regex, 'ferret')); -// Expected output: "The quick brown fox jumps over the lazy ferret. If the dog reacted, was it really lazy?" +console.log(paragraph.replace(regex, 'ferret')); +// Expected output: "I think Ruth's ferret is cuter than your dog!" diff --git a/live-examples/js-examples/string/string-replaceall.js b/live-examples/js-examples/string/string-replaceall.js index 613764e2d..e84c64fa2 100644 --- a/live-examples/js-examples/string/string-replaceall.js +++ b/live-examples/js-examples/string/string-replaceall.js @@ -1,10 +1,9 @@ -const p = - 'The quick brown fox jumps over the lazy dog. If the dog reacted, was it really lazy?'; +const paragraph = "I think Ruth's dog is cuter than your dog!"; -console.log(p.replaceAll('dog', 'monkey')); -// Expected output: "The quick brown fox jumps over the lazy monkey. If the monkey reacted, was it really lazy?" +console.log(paragraph.replaceAll('dog', 'monkey')); +// Expected output: "I think Ruth's monkey is cuter than your monkey!" // Global flag required when calling replaceAll with regex const regex = /Dog/gi; -console.log(p.replaceAll(regex, 'ferret')); -// Expected output: "The quick brown fox jumps over the lazy ferret. If the ferret reacted, was it really lazy?" +console.log(paragraph.replaceAll(regex, 'ferret')); +// Expected output: "I think Ruth's ferret is cuter than your ferret!" diff --git a/live-examples/js-examples/string/string-search.js b/live-examples/js-examples/string/string-search.js index ea6184405..d6ac2e1a5 100644 --- a/live-examples/js-examples/string/string-search.js +++ b/live-examples/js-examples/string/string-search.js @@ -1,11 +1,10 @@ -const paragraph = - 'The quick brown fox jumps over the lazy dog. If the dog barked, was it really lazy?'; +const paragraph = "I think Ruth's dog is cuter than your dog!"; -// Any character that is not a word character or whitespace -const regex = /[^\w\s]/g; +// Anything not a word character, whitespace or apostrophe +const regex = /[^\w\s']/g; console.log(paragraph.search(regex)); -// Expected output: 43 +// Expected output: 41 console.log(paragraph[paragraph.search(regex)]); -// Expected output: "." +// Expected output: "!"