Issue with Return a Value from a Function with Return
See original GitHub issueChallenge Return a Value from a Function with Return has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code: function timesFive(num){ return num * 5; } var answer = timesFive(5);
// Example function minusSeven(num) { return num - 7; } var answer = minusSeven(7); // Only change code below this line
**The console deck won't change no matter what you type in. Always showing "timesFive(5)===25".**
People who have this kind of problem could go to this link and test:
https://jsbin.com/daxoyifabe/edit?html,css,output
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:19 (12 by maintainers)
Top Results From Across the Web
Function return values - Learn web development | MDN
When the function completes (finishes running), it returns a value, which is a new string with the replacement made. In the code above,...
Read more >Return a Value from a Function with Return - CodeChallenge
Instructions. Create a function timesFive that accepts one argument, multiplies it by 5 , and returns the new value.
Read more >2.2 — Function return values (value-returning functions)
The specific value returned from a function is called the return value. When the return statement is executed, the function exits immediately, ...
Read more >The Python return Statement: Usage and Best Practices
You can use the return statement to make your functions send Python objects back to the caller code. These objects are known as...
Read more >does return statement actually return the value or store it in ...
Because the return value of a function is an rvalue, it does not have an address. So to answer your question, when you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This has to do with how the challenge code and tests are run when a user clicks “Run Tests.” In this case, the “tail” of the challenge attempts to call
timesFive
with an argument of5
if it is a valid function and returns the result to show the user what the output is for that input, and returns “timesFive is not a function” otherwise.However in many other challenges, the output will reflect the returned value of a call to the function if one is included at the end of the code, but this is not the case here. Even with the final line
timesFive(2)
(with or without assignment to a variable) the output will display"timesFive(5)===25"
as @zcloud421 correctly stated.The challenge tail should be reviewed to allow users to test their own values with their newly written function, as this is one of the first opportunities in the course for them to do so (with a function written from scratch). As assigning the returned value of the function to
answer
prevents the output from displaying, this should probably be removed from the example code also. It isn’t really needed sinceanswer
is not subsequently used, and “Assignment with a Returned Value” is the aim of the following challenge anyway.Since this has been inactive for a while, I thought I’d give this a shot 😄