Beginners JavaScript
  • Welcome!
  • Tutorial
    • Step 1: Hello World
    • Step 2: Data Types
    • Step 3: Comments
    • Step 4: Variables
    • Step 5: If/Else Statements
    • Step 6: For Loops
    • Step 7: Functions
    • Step 8: Arrays
    • Step 9: Objects
  • Challenges
    • Challenge 1: Age Difference
    • Challenge 2: Famous Writers
    • Challenge 3: Fix the Code
    • Challenge 4: FizzBuzz
    • Challenge 5: Needle in a Haystack
Powered by GitBook
On this page
  1. Challenges

Challenge 3: Fix the Code

The following code invokes a function called 'add' that adds two numbers together. When you run this code, it should add 13 to 27, and output '40' to the console.

But this code is broken! Using your newfound JavaScript knowledge, find the bugs and fix it.

var first number = 13;
var second number = 27;
​
function 'add' () {
  return x + y;
}
​
add(first number, second number);
PreviousChallenge 2: Famous WritersNextChallenge 4: FizzBuzz

Last updated 6 years ago