Dollar Dollar Bill explainer


#1

The aim of this puzzle: Complete the inDollars function definition so that it converts cents into dollars.

Walkthrough of the solution: In between the 2 console.log(...) calls, the inDollars() function is called. When the puzzle starts, the function takes in an argument and stores it in cents. Then it assigns that value to wallet. Instead of doing that, we want to calcluate how many dollars those cents are worth and then store that inside wallet.

There are 100 cents in each dollar, so that means we divide cents by 100 to get the amount of dollars. Change wallet = cents into wallet = cents / 100, by using the / key, then the num key to insert 100.

Sample code solution:
(Tap below to reveal)

let wallet = 3600;

function inDollars(cents) {
  wallet = cents / 100;
}

console.log('You have ' + wallet + ' cents.');
inDollars(wallet);
console.log('You have ' + wallet + ' dollars.');

JavaScript Concepts: Arithmetic Operators (/), Binary Expression (+ concatenation), Calling Functions, Function Declarations, Code Block (function), console.log() , Variable Scope (let)


#2

Instructions state to divide wallet by 100.
W=c/100
I feel instructions should have stated divide cents by 100
Not sure