Skip to content

Conversation

@Folyd
Copy link
Member

@Folyd Folyd commented Mar 10, 2025

let numbers = [10, 5, 8, 3, 1];
print(numbers);  // expect: [10, 5, 8, 3, 1]

// append - Add an item to the end
numbers.append(20);
print(numbers);  // expect: [10, 5, 8, 3, 1, 20]

// extend - Extend with another array
numbers.extend([30, 40]);
print(numbers);  // expect: [10, 5, 8, 3, 1, 20, 30, 40]

// insert - Insert an item at position
numbers.insert(2, 15);
print(numbers);  // expect: [10, 5, 15, 8, 3, 1, 20, 30, 40]

// index - Find position of value
let pos = numbers.index(15);
print(pos);  // expect: 2

@Folyd Folyd merged commit 7979470 into main Mar 10, 2025
6 checks passed
@Folyd Folyd deleted the array-methods branch March 10, 2025 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants