0
0
Javascriptprogramming~5 mins

Output formatting basics in Javascript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is output formatting in programming?
Output formatting means arranging and displaying data in a way that is easy to read and understand.
Click to reveal answer
beginner
How do you print a variable with text in JavaScript using template literals?
Use backticks `` and ${variable} inside them. Example: console.log(`Hello, ${name}!`);
Click to reveal answer
beginner
What does console.log() do in JavaScript?
It prints messages or values to the browser console or terminal, helping you see output or debug your code.
Click to reveal answer
intermediate
How can you format numbers to show two decimal places in JavaScript?
Use the <code>toFixed(2)</code> method. Example: <code>let price = 5.6789; console.log(price.toFixed(2)); // 5.68</code>
Click to reveal answer
beginner
Why is output formatting important?
It makes data clear and easy to understand, which helps users and developers avoid mistakes and confusion.
Click to reveal answer
Which symbol is used to create template literals in JavaScript?
ABackticks (`)
BSingle quotes (')
CDouble quotes (")
DParentheses ()
What does console.log('Hello, ' + name); do?
APrints 'Hello, ' followed by the value of name
BCreates a new variable called console
CStops the program
DFormats a number
How do you limit a number to 2 decimal places in JavaScript?
Anumber.toString(2)
Bnumber.toFixed(2)
Cnumber.round(2)
Dnumber.format(2)
Which method prints output to the console in JavaScript?
Aecho()
Bprint()
Cconsole.log()
Dwrite()
Why use output formatting?
ATo delete data
BTo slow down the program
CTo hide errors
DTo make output clear and readable
Explain how to use template literals in JavaScript to format output with variables.
Think about how to combine text and variables in one string.
You got /4 concepts.
    Describe why formatting numbers to fixed decimal places is useful in output.
    Consider how numbers look when printed to users.
    You got /4 concepts.