Back to Freecodecamp

Step 10

curriculum/challenges/english/blocks/learn-basic-javascript-by-building-a-role-playing-game/62a3b41c9494f937560640ab.md

latest1.6 KB
Original Source

--description--

Declare two more variables named monsterHealth and inventory.

For your inventory variable, assign it the value of an array containing the string "stick".

Remember that you worked with arrays in the previous project like this:

js
let exampleArray = ["first", "second", "third"];

--hints--

You should use let to declare your monsterHealth variable.

js
assert.match(code, /let\s+monsterHealth/i);

You should use camelCase to name your monsterHealth variable.

js
assert.match(code, /monsterHealth/);

monsterHealth should not have a value.

js
assert.isUndefined(monsterHealth);

You should not assign a value to your monsterHealth variable.

js
assert.match(code, /let\s+monsterHealth\s*;?/);

You should use let to declare your inventory variable.

js
assert.match(code, /let\s+inventory/i);

Your inventory variable should still be an array.

js
assert.isArray(inventory);

Your inventory variable should only have one value.

js
assert.lengthOf(inventory, 1);

Your inventory variable should include the string "stick".

js
assert.include(inventory, "stick");

--seed--

--seed-contents--

html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="./styles.css">
    <title>RPG - Dragon Repeller</title>
    <script src="./script.js"></script>
  </head>
  <body>
    <div id="game">
    </div>
  </body>
</html>
js
--fcc-editable-region--
let xp = 0;
let health = 100;
let gold = 50;
let currentWeaponIndex = 0;
let fighting;
--fcc-editable-region--