From de8655d5287e60427da6a8cfcbc1d425f3ab35c5 Mon Sep 17 00:00:00 2001 From: Dinesh Bajgain Date: Mon, 25 May 2026 02:14:18 +0545 Subject: [PATCH] fix(curriculum): fix grammar and wording in arrays tutorials (#67502) Signed-off-by: Dinesh Bajgain Co-authored-by: majestic-owl448 <26656284+majestic-owl448@users.noreply.github.com> --- .../67329f508a6ec45b046700b3.md | 2 +- .../6732aebaa8abb9086a9bb17a.md | 10 +++++----- .../6732b2a6de5a1c15edf05b75.md | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/curriculum/challenges/english/blocks/lecture-working-with-arrays/67329f508a6ec45b046700b3.md b/curriculum/challenges/english/blocks/lecture-working-with-arrays/67329f508a6ec45b046700b3.md index 1f5d10ff17d..2c833bdf4f3 100644 --- a/curriculum/challenges/english/blocks/lecture-working-with-arrays/67329f508a6ec45b046700b3.md +++ b/curriculum/challenges/english/blocks/lecture-working-with-arrays/67329f508a6ec45b046700b3.md @@ -31,7 +31,7 @@ console.log(fruits[2]); // "orange" In this example, we use the index `0` to access the first element (`apple`) and the index `2` to access the third element (`orange`). -Arrays in JavaScript have a special `length` property that returns the number of elements in the array. You can access this property using the `length` keyword. For example: +Arrays in JavaScript have a special `length` property that returns the number of elements in the array. You can access this property using the `length` property. For example: :::interactive_editor diff --git a/curriculum/challenges/english/blocks/lecture-working-with-arrays/6732aebaa8abb9086a9bb17a.md b/curriculum/challenges/english/blocks/lecture-working-with-arrays/6732aebaa8abb9086a9bb17a.md index a22fe7a2f79..807279f7d2d 100644 --- a/curriculum/challenges/english/blocks/lecture-working-with-arrays/6732aebaa8abb9086a9bb17a.md +++ b/curriculum/challenges/english/blocks/lecture-working-with-arrays/6732aebaa8abb9086a9bb17a.md @@ -7,7 +7,7 @@ dashedName: how-do-you-access-and-update-elements-in-an-array # --interactive-- -In the previous lesson, you were first introduced to working with arrays and accessing different elements from arrays. Here is a reminder on how to access the second element from an array: +In the previous lesson, you were introduced to working with arrays and accessing different elements in arrays. Here is a reminder of how to access the second element in an array: :::interactive_editor @@ -19,7 +19,7 @@ console.log(fruits[1]); // "banana" ::: -Since arrays are zero based indexed, the first element will be at index `0`, the second index will be at index `1`, etc. It's important to note that if you try to access an index that doesn't exist in the array, JavaScript will return `undefined`. +Since arrays are zero-based indexed, the first element will be at index `0`, the second element is at index `1`, and so on. It's important to note that if you try to access an index that doesn't exist in the array, JavaScript will return `undefined`. :::interactive_editor @@ -30,7 +30,7 @@ console.log(fruits[3]); // undefined ::: -In this example, there is no index `3` for the `fruits` array. So the log will show `undefined`. Now, let's look at how to update elements in an array. You can update an element by assigning a new value to a specific index. +In this example, there is no element at index `3` for the `fruits` array. So the log will show `undefined`. Now, let's look at how to update elements in an array. You can update an element by assigning a new value to a specific index. :::interactive_editor @@ -42,7 +42,7 @@ console.log(fruits); // ["apple", "blueberry", "cherry"] ::: -In this example, we've replaced `banana` with `blueberry` at index `1`. This method allows you to change any element in the array, as long as you know its index. You can also add new elements to an array by assigning a value to an index that doesn't yet exist: +In this example, we replaced `banana` with `blueberry` at index `1`. This method allows you to change any element in the array, as long as you know its index. You can also add new elements to an array by assigning a value to an index that doesn't yet exist: :::interactive_editor @@ -54,7 +54,7 @@ console.log(fruits); // ["apple", "banana", "cherry", "date"] ::: -However, exercise caution when doing this. If you assign a value to an index that is much larger than the current length of the array, you will create undefined elements for the indices in between, which can lead to unexpected behavior. As you continue to work with JavaScript, you'll find that these ways of accessing and updating array elements are fundamental to many programming tasks. Whether you're building a simple todo list or processing complex data structures, these skills will be invaluable. +However, exercise caution when doing this. If you assign a value to an index that is much larger than the current length of the array, you will create undefined elements for the indices in between, which can lead to unexpected behavior. As you continue to work with JavaScript, you'll find that these methods of accessing and updating array elements are fundamental to many programming tasks. Whether you're building a simple todo list or processing complex data structures, these skills will be invaluable. # --questions-- diff --git a/curriculum/challenges/english/blocks/lecture-working-with-arrays/6732b2a6de5a1c15edf05b75.md b/curriculum/challenges/english/blocks/lecture-working-with-arrays/6732b2a6de5a1c15edf05b75.md index ae8052bf8a5..fded99df33e 100644 --- a/curriculum/challenges/english/blocks/lecture-working-with-arrays/6732b2a6de5a1c15edf05b75.md +++ b/curriculum/challenges/english/blocks/lecture-working-with-arrays/6732b2a6de5a1c15edf05b75.md @@ -23,7 +23,7 @@ The first step in reversing a string is to convert it into an array of individua - A dash (`"-"`), which splits the string at each dash. -Here's an example of using the split method to create an array of characters: +Here's an example of using the `split()` method to create an array of characters: :::interactive_editor @@ -35,9 +35,9 @@ console.log(charArray); // ["h", "e", "l", "l", "o"] ::: -In this example, we use `split("")` (with an empty string pass to it) to convert the string `hello` into an array of its individual characters. Once we have an array of characters, we can use the `reverse()` method to reverse the order of elements in the array. +In this example, we use `split("")` (with an empty string as the argument) to convert the string `hello` into an array of its individual characters. Once we have an array of characters, we can use the `reverse()` method to reverse the order of elements in the array. -The `reverse()` method is an array method that reverses an array in place. This means it modifies the original array rather than creating a new one. Here's how we can use it: +The `reverse()` method is an array method that reverses the elements of an array in place. This means it modifies the original array rather than creating a new one. Here's how we can use it: :::interactive_editor @@ -49,9 +49,9 @@ console.log(charArray); // ["o", "l", "l", "e", "h"] ::: -In this example, `reverse()` changes the order of elements in `charArray`, reversing it from `["h", "e", "l", "l", "o"]` to `["o", "l", "l", "e", "h"]`. +In this example, `reverse()` changes the order of the elements in `charArray`, reversing it from `["h", "e", "l", "l", "o"]` to `["o", "l", "l", "e", "h"]`. -The final step is to convert the reversed array of characters back into a string. We can accomplish this using the `join()` method. The `join()` method creates and returns a new string by concatenating all of the elements in an array, separated by a specified separator string. If you want to join the characters without any separator, you can use an empty string as the argument. Here's an example: +The final step is to convert the reversed array of characters back into a string. We can accomplish this using the `join()` method. The `join()` method creates and returns a new string by concatenating all the elements in an array, separated by a specified separator string. If you want to join the characters without any separator, you can use an empty string as the argument. Here's an example: :::interactive_editor @@ -63,7 +63,7 @@ console.log(reversedString); // "olleh" ::: -In this example, `join("")` (with an empty string pass to it as an argument) combines all the characters in the array into a single string without any separator between them. +In this example, `join("")` (with an empty string passed to it as an argument) combines all the characters in the array into a single string without any separator between them. Remember that strings in JavaScript are immutable, which means you can't directly reverse a string by modifying it. That's why we need to convert it to an array, reverse the array, and then convert it back to a string. This combination of string and array methods provides a powerful and flexible way to manipulate strings in JavaScript.