Skip to content
18 changes: 16 additions & 2 deletions content/javascript/concepts/strings/terms/charAt/charAt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 `.charAt()` 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(3.5));
```
26 changes: 20 additions & 6 deletions content/javascript/concepts/strings/terms/concat/concat.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Concatenates or combines strings together.

## Syntax

```js
```pseudo
string.concat(string_1, string_2, string_3);
```

Expand All @@ -25,18 +25,32 @@ 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

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

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));
```
19 changes: 17 additions & 2 deletions content/javascript/concepts/strings/terms/indexOf/indexOf.md
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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);
```

Expand Down Expand Up @@ -70,3 +70,18 @@ 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
// Declaring a string
const myString = 'I love JavaScript! ';

// Case 1: Target value exists
console.log(myString.indexOf('love'));

// Case 2: Target value does not exist
console.log(myString.indexOf('hate'));
```