

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Functions
incomplete
2: Function Hoisting
incomplete
3: Unit Test Lessons
incomplete
4: Multiple Return Values
incomplete
5: Functions As Values
incomplete
6: Scope
incomplete
7: Anonymous Functions
incomplete
8: Default Parameters
incomplete
9: Passing by Value
incomplete
10: Immediate Invocation
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Many languages allow multiple values to be returned from a function. For example, in Python this works:
def get_user():
return "[email protected]", 21, "active"
email, age, status = get_user()
However, in JavaScript, that's not allowed!
function getUser() {
return "[email protected]", 21, "active";
// DON'T DO THIS
// it only returns 'active'
}
Strangely, the JavaScript code above won't actually throw any sort of error, it will just silently return the "active" string.... which is unintuitive behavior that you probably didn't want. You can only return one value from a function in JavaScript!
To get around this, most developers return an object that contains the values they want to return. We'll cover objects later.
Textio has a built in profanity detector, but it's currently broken. Fix the isClean function so that it only returns the boolean representing whether the given message contains no profanity.