Let’s update the incrementer
function to clearly declare its dependencies.
Write the incrementer
function so it takes an argument, and then returns a result after increasing the value by one.
Your code so far
// The global variable
var fixedValue = 4;
// Only change code below this line
function incrementer () {
// Only change code above this line
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36
.
Challenge: Pass Arguments to Avoid External Dependence in a Function
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
Remember to read the directions: Modify it so it takes an argument, and return the argument plus one.
1 Like
I did it like this but it doesn’t work.
// The global variable
var fixedValue = 4;
// Only change code below this line
function incrementer (value) {
return value + 1;
// Only change code above this line
}
var newValue = incrementer (fixedValue );
You added something extra on the end.
anon58011934:
fixedValue
I think I need to omit var newValue
In the code, it says “Only change code above this line”. You don’t need to call the function, you just need to make it.
1 Like
Yes I understood. Many thanks
1 Like