Back to Freecodecamp

Step 6

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

latest1.3 KB
Original Source

--description--

Remove your console.log("Hello World"); line to begin writing your project code.

In the previous project, you learned how to work with variables and the let keyword like this:

js
let camperbot;

You also learned how to initialize a variable with a value like this:

js
let age = 32;

Use the let keyword to declare a variable called xp and assign it the value of 0, a number.

--hints--

You should not have a console.log("Hello World"); line in your code.

js
assert.notMatch(code, /console\.log\(\s*('|")Hello World\1\s*\)\s*;/);

You should use the let keyword to declare your variable.

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

You should declare a variable named xp.

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

xp should have a value of 0.

js
assert.equal(xp, 0);

You should initialize the xp variable to 0.

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

--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--
console.log("Hello World");
--fcc-editable-region--