From 0ceb252c94750bd1dc1c3fc865f1b46b6c2e90ec Mon Sep 17 00:00:00 2001 From: Mehboob Ali Date: Sat, 24 Jun 2023 15:24:48 +0500 Subject: [PATCH 1/7] js codebyte added for charAt --- .../concepts/strings/terms/charAt/charAt.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/content/javascript/concepts/strings/terms/charAt/charAt.md b/content/javascript/concepts/strings/terms/charAt/charAt.md index d5002b508ee..2bb647815f6 100644 --- a/content/javascript/concepts/strings/terms/charAt/charAt.md +++ b/content/javascript/concepts/strings/terms/charAt/charAt.md @@ -45,3 +45,17 @@ const lastLetter = greeting.charAt(greeting.length - 1); console.log(lastLetter); // Output: d ``` + +## Codebyte Example + +The following is runnable, and demonstrates the use of the `.chatAt()` method: + +```codebyte/javascript +const myString = 'I love JavaScript! ' + +// Using integer value +console.log(myString.charAt(2)); + +// Using decimal value that gets rounded down from 3.5 to 3 +console.log(myString.charAt(2)); +``` From b4a792231359d749c41732c8f148b9f2b8e94692 Mon Sep 17 00:00:00 2001 From: Mehboob Ali Date: Sat, 24 Jun 2023 15:30:44 +0500 Subject: [PATCH 2/7] js code bytes added for concat --- .../concepts/strings/terms/concat/concat.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/content/javascript/concepts/strings/terms/concat/concat.md b/content/javascript/concepts/strings/terms/concat/concat.md index 596df3194d1..9181360dd11 100644 --- a/content/javascript/concepts/strings/terms/concat/concat.md +++ b/content/javascript/concepts/strings/terms/concat/concat.md @@ -40,3 +40,17 @@ const y = 'Cappuccino?'; console.log('Hey Bob! '.concat(x, ' ', y)); // Output: Hey Bob! Do you like Latte or Cappuccino? ``` + +## Codebyte Example + +The following is runnable, and demonstrates the use of the `.concat()` method: + +```codebyte/javascript +// Concatenating a string directly: +console.log('I love JavaScript'.concat(' and Go')); + +// Concatenating strings using variables +const myString = 'I love JavaScript ' +const myString2 = 'and Go'; +console.log(myString.concat(myString2)); +``` From a3a63f0e50b482e79688b219cf94dcb829c2fcd6 Mon Sep 17 00:00:00 2001 From: Mehboob Ali Date: Sat, 24 Jun 2023 15:31:05 +0500 Subject: [PATCH 3/7] type fixed in charAt js codebyte --- content/javascript/concepts/strings/terms/charAt/charAt.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/javascript/concepts/strings/terms/charAt/charAt.md b/content/javascript/concepts/strings/terms/charAt/charAt.md index 2bb647815f6..7f06153c626 100644 --- a/content/javascript/concepts/strings/terms/charAt/charAt.md +++ b/content/javascript/concepts/strings/terms/charAt/charAt.md @@ -48,10 +48,10 @@ console.log(lastLetter); ## Codebyte Example -The following is runnable, and demonstrates the use of the `.chatAt()` method: +The following is runnable, and demonstrates the use of the `.charAt()` method: ```codebyte/javascript -const myString = 'I love JavaScript! ' +const myString = 'I love JavaScript! '; // Using integer value console.log(myString.charAt(2)); From 4e850298a9d15c8433d1bd51db803069b4f18cf5 Mon Sep 17 00:00:00 2001 From: Mehboob Ali Date: Sat, 24 Jun 2023 15:38:28 +0500 Subject: [PATCH 4/7] js codebytes added for indexOf --- .../concepts/strings/terms/indexOf/indexOf.md | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/content/javascript/concepts/strings/terms/indexOf/indexOf.md b/content/javascript/concepts/strings/terms/indexOf/indexOf.md index 3ecaac51f67..ec66f117e8b 100644 --- a/content/javascript/concepts/strings/terms/indexOf/indexOf.md +++ b/content/javascript/concepts/strings/terms/indexOf/indexOf.md @@ -70,3 +70,27 @@ const didYouFindWaldo = people.indexOf('Waldo'); console.log(didYouFindWaldo); // Output: -1 ``` + +## Codebyte Example + +The following is runnable, and demonstrates the use of the `.indexOf()` method: + +```codebyte/javascript +// Using a string +const myString = 'I love JavaScript! '; + +// Case 1: Searchable value exists +console.log(myString.indexOf('love')); + +// Case 2: Searchable value does not exist +console.log(myString.indexOf('hate')); + +// Using an array +const myArray = ['Javascript, Python, Ruby, GO']; + +// Case 1: Searchable value exists +console.log(myArray.indexOf('GO')); + +// Case 2: Searchable value does not exist +console.log(myArray.indexOf('C++')); +``` From 08c9704ce879e4190dcac5f369c13fd6c1ea9d26 Mon Sep 17 00:00:00 2001 From: Mehboob Ali Date: Sun, 25 Jun 2023 22:59:17 +0500 Subject: [PATCH 5/7] remove array codebyte example --- .../javascript/concepts/strings/terms/indexOf/indexOf.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/content/javascript/concepts/strings/terms/indexOf/indexOf.md b/content/javascript/concepts/strings/terms/indexOf/indexOf.md index ec66f117e8b..c34052a7307 100644 --- a/content/javascript/concepts/strings/terms/indexOf/indexOf.md +++ b/content/javascript/concepts/strings/terms/indexOf/indexOf.md @@ -84,13 +84,4 @@ console.log(myString.indexOf('love')); // Case 2: Searchable value does not exist console.log(myString.indexOf('hate')); - -// Using an array -const myArray = ['Javascript, Python, Ruby, GO']; - -// Case 1: Searchable value exists -console.log(myArray.indexOf('GO')); - -// Case 2: Searchable value does not exist -console.log(myArray.indexOf('C++')); ``` From f018461189d02be2acb039f79d2db3061d70d7b7 Mon Sep 17 00:00:00 2001 From: Mehboob Ali Date: Sun, 25 Jun 2023 22:59:30 +0500 Subject: [PATCH 6/7] fixed typo --- content/javascript/concepts/strings/terms/charAt/charAt.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/javascript/concepts/strings/terms/charAt/charAt.md b/content/javascript/concepts/strings/terms/charAt/charAt.md index 7f06153c626..3d490d7528e 100644 --- a/content/javascript/concepts/strings/terms/charAt/charAt.md +++ b/content/javascript/concepts/strings/terms/charAt/charAt.md @@ -57,5 +57,5 @@ const myString = 'I love JavaScript! '; console.log(myString.charAt(2)); // Using decimal value that gets rounded down from 3.5 to 3 -console.log(myString.charAt(2)); +console.log(myString.charAt(3.5)); ``` From 8a36e8866d036779f0a04831597c827253aea18b Mon Sep 17 00:00:00 2001 From: Caupolican Diaz Date: Tue, 27 Jun 2023 15:03:42 -0700 Subject: [PATCH 7/7] review edits --- .../concepts/strings/terms/charAt/charAt.md | 4 ++-- .../concepts/strings/terms/concat/concat.md | 12 ++++++------ .../concepts/strings/terms/indexOf/indexOf.md | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/content/javascript/concepts/strings/terms/charAt/charAt.md b/content/javascript/concepts/strings/terms/charAt/charAt.md index 3d490d7528e..8905cb96153 100644 --- a/content/javascript/concepts/strings/terms/charAt/charAt.md +++ b/content/javascript/concepts/strings/terms/charAt/charAt.md @@ -16,11 +16,11 @@ Returns a single character at the specified index of a string. ## Syntax -```js +```pseudo string.charAt(index); ``` -`index` is a required parameter representing the index of the character you want to return. +`index` is a required parameter representing the index of the character to be returned. ## Examples diff --git a/content/javascript/concepts/strings/terms/concat/concat.md b/content/javascript/concepts/strings/terms/concat/concat.md index 9181360dd11..c18b1bddc54 100644 --- a/content/javascript/concepts/strings/terms/concat/concat.md +++ b/content/javascript/concepts/strings/terms/concat/concat.md @@ -16,7 +16,7 @@ Concatenates or combines strings together. ## Syntax -```js +```pseudo string.concat(string_1, string_2, string_3); ``` @@ -25,8 +25,8 @@ string.concat(string_1, string_2, string_3); Concatenating a string: ```js -console.log('Do you like Latte or '.concat('Cappuccino?')); -// Output: Do you like Latte or Cappuccino? +console.log('Would you like a latte or '.concat('cappuccino?')); +// Output: Would you like a latte or cappuccino? ``` ## Example 2 @@ -34,11 +34,11 @@ console.log('Do you like Latte or '.concat('Cappuccino?')); Concatenating strings with the usage of variables: ```js -const x = 'Do you like Latte or'; -const y = 'Cappuccino?'; +const x = 'Would you like a latte or'; +const y = 'cappuccino?'; console.log('Hey Bob! '.concat(x, ' ', y)); -// Output: Hey Bob! Do you like Latte or Cappuccino? +// Output: Hey Bob! Would you like a latte or cappuccino? ``` ## Codebyte Example diff --git a/content/javascript/concepts/strings/terms/indexOf/indexOf.md b/content/javascript/concepts/strings/terms/indexOf/indexOf.md index c34052a7307..af2a8b65c9f 100644 --- a/content/javascript/concepts/strings/terms/indexOf/indexOf.md +++ b/content/javascript/concepts/strings/terms/indexOf/indexOf.md @@ -1,6 +1,6 @@ --- Title: '.indexOf()' -Description: 'Searches a string for a given value and returns the first index if found. Returns -1 if not found.' +Description: 'Searches a string for a given value and returns the first index if found.' Subjects: - 'Web Development' - 'Computer Science' @@ -16,7 +16,7 @@ Searches a string for a given value and returns the first index if found. Return ## Syntax -```js +```pseudo string.indexOf(value, startSearch); ``` @@ -76,12 +76,12 @@ console.log(didYouFindWaldo); The following is runnable, and demonstrates the use of the `.indexOf()` method: ```codebyte/javascript -// Using a string +// Declaring a string const myString = 'I love JavaScript! '; -// Case 1: Searchable value exists +// Case 1: Target value exists console.log(myString.indexOf('love')); -// Case 2: Searchable value does not exist +// Case 2: Target value does not exist console.log(myString.indexOf('hate')); ```