freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../functional-programming/pass-arguments-to-avoid-ext...

1.2 KiB

id title challengeType videoUrl localeTitle
587d7b8e367417b2b2512b5f Pass Arguments to Avoid External Dependence in a Function 1

Description

undefined

Instructions

undefined

Tests

tests:
  - text: ''
    testString: 'assert(fixedValue === 4, "Your function <code>incrementer</code> should not change the value of <code>fixedValue</code>.");'
  - text: ''
    testString: 'assert(code.match(/function\s+?incrementer\s*?\(.+?\)/g), "Your <code>incrementer</code> function should take a parameter.");'
  - text: ''
    testString: 'assert(newValue === 5, "Your <code>incrementer</code> function should return a value that is one larger than the <code>fixedValue</code> value.");'

Challenge Seed

// the global variable
var fixedValue = 4;

// Add your code below this line
function incrementer () {


  // Add your code above this line
}

var newValue = incrementer(fixedValue); // Should equal 5
console.log(fixedValue); // Should print 4

Solution

// solution required