

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 6
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
Up until now, all the coding lessons in this course have tested your code's console output (what's printed). For example, a lesson might expect your code (in conjunction with the code we provide) to console.log something like:
Price: 0.2
NumMessages: 18
If your code prints that exact output, you pass. If it doesn't, you fail. Haw-haw.
Going forward, you'll also encounter a new type of lesson: unit tests. If this isn't your first course with us, you'll know what I'm talking about, but in case you haven't, a unit test is just an automated program that tests a small "unit" of code. Usually just a function or two. Your editor will now have multiple tabs: the main.js file containing your code, and the main_test.js file containing our unit tests.
These new unit-test-style lessons will test your code's functionality rather than its output. Our tests will call functions in your code with different arguments, and expect specific return values. If your code returns the correct values, you pass. If it doesn't, you fail.
There are two reasons for this change:
console.log statements, and leave those print statements in when you submit. Unlike the output-based lessons, you won't have to remove your console.log statements to pass.Complete the getMonthlyPrice function. It accepts a tier (string) as input and returns the monthly price for that tier in pennies.
Here are the prices in dollars:
Convert the prices from dollars to pennies. If the given tier doesn't match any of the above, return 0 pennies.
To avoid pesky floating-point errors, we often store prices in the currency's base unit. In this case, we are storing the prices in pennies, and a dollar consists of 100 pennies.