HTML Academy
A few more operations
Introduction to programming12/15
Back to the list of tasks
  • 1. Career start
  • 2. Making the program a bit more complicated
  • 3. Console log
  • 4. Data types
  • 5. Complex data types
  • 6. Unknown data
  • 7. Variables
  • 8. Declaring and assigning variables
  • 9. Operations
  • 10. Operations order
  • 11. A few more operations
  • 12. Release of Brekkie-meter v0.1, part 1
  • 13. Release of Brekkie-meter v0.1, part 2
  • 14. Summary of “Getting to know JavaScript”
  • 15. First program: MufFit v0.1
Release of Brekkie-meter v0.1, part 2
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Release of Brekkie-meter v0.1, part 1

We’ve got it all now! You are now ready to fully solve Muffin’s third task. And not just solve it, but make the program more user-friendly and intuitive. Let us remind you about the task:

Third task: “Write a program for calculating the caloric value of my breakfast. I have milk for breakfast. I want to enter the amount of milk I drank and see its caloric value.”

Let’s break the solution down into several steps:

  1. collect breakfast data from Muffin,
  2. save this data to a variable for further processing,
  3. show a message that the data has been received, so that Muffin is no longer worried,
  4. process data using mathematical operations where we use our first variable,
  5. save the result of our calculations to a second variable,
  6. and show a message with the result of our program’s work.

Let’s first deal with the first three steps and cover the other three in the next task.

Working together: we come up with variable names, texts, and formulas, you write the code.

Comments

  • script.js
JavaScript
console.log('Brekkie-meter v0.1 is launched');

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

Console

The code has changed, click “Run” or turn autorun on.

Result

Goalscompleted
  1. Declare variable milkInGrams,
  2. use it to save data from the muffin.ask command with the question “Boss, how many grams of milk have you had?”
  3. Send the following message made of three string fragments to the console: 'Brekkie-meter has received milk data. Consumed ', variable milkInGrams, string ' grams.'.

Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

VISAMastercard

Log in

or

Forgot your password?

Sign up

Sign up

or
Log in

Restore access

Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

Forgot to connect your email to the profile? Email us and we’ll help.