mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-13 06:04:13 -04:00
fix(curriculum): adds code examples for shift method for RPG Game (#53325)
This commit is contained in:
committed by
GitHub
parent
e25cc57b75
commit
7316e800ba
@@ -7,7 +7,14 @@ dashedName: step-104
|
||||
|
||||
# --description--
|
||||
|
||||
The `shift()` method on an array removes the first element in the array and returns it. Use this method to take the first element from the `inventory` array and assign it to your `currentWeapon` variable.
|
||||
The `shift()` method on an array removes the first element in the array and returns it.
|
||||
|
||||
```js
|
||||
const numbers = [1, 2, 3];
|
||||
const firstNumber = numbers.shift(); // returns 1
|
||||
```
|
||||
|
||||
Use the `shift()` method to take the first element from the `inventory` array and assign it to your `currentWeapon` variable.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
||||
Reference in New Issue
Block a user