GitHub Repository Submission

When using GitHub mode, paste your repository URL below and click Save URL to store it. The saved URL will be automatically included with every message you send until you choose to clear it. Learn more

Your GitHub repository URL is saved. LSBot will automatically fetch your latest code from this repository for each message. To change the URL, clear it first and save a new one.

Exercise 9

Identify all of the variables named on each line of the following code. You may assume that question is the name of a built-in function in JavaScript (it is not, so this code won't work as written).

function multiply(left, right) {
  let product = left * right;
  return product;
}

function getNumber(prompt) {
  return parseFloat(question(prompt));
}

let left = getNumber('Enter the first number: ');
let right = getNumber('Enter the second number: ');
console.log(`${left} * ${right} = ${multiply(left, right)}`);

Solution

  • Line 1: multiply, left, right: The function name and the parameter names are all variable names.
  • Line 2: product, left, right
  • Line 3: product
  • Line 6: getNumber, prompt
  • Line 7: parseFloat, question, prompt. This one is a little tricky. parseFloat is an actual built-in function in JavaScript; we are pretending that question also is a built-in function. As such, we know that both parseFloat and question are variable names.
  • Line 10: left, getNumber
  • Line 11: right, getNumber
  • Line 12: console, left, right, multiply: console.log is a little tricky here. console is the variable name for the built-in Console object. In contrast, console.log is the name of a method in that object. As such, log is a property name, not a variable name.

Video Walkthrough

Hi! I'm LSBot. I can help you think through the selected exercise by giving you hints and guidance without revealing the solution. Your code from the editor will be automatically detected. Want to know more? Refer to the LSBot User Guide .

Detected solution
Loading...

Submit your solution for LSBot review.

Hi! I'm LSBot. Your code from the editor will be automatically detected. I'll review your solution and provide feedback to help you improve. Ask questions about your solution or request a comprehensive code review. Want to know more? Refer to the LSBot User Guide .

Detected solution
Loading...