Kilometres to Metres
Programming Basics · JavaScript
TASK
Problem
Given an integer number of kilometres `km`, convert it to metres.
EXAMPLE
Example
7
7000
LIMITS
Constraints
All numeric input values fit in JavaScript `Number`.
LEARN
Theory for this problem
+
### Kilometres to Metres
JavaScript arithmetic works with numeric values stored in variables. A clear solution reads the needed values, computes the formula with `+`, `-`, `*`, `/` or `**`, and prints only the final result.
NEED HELP?
Hints
+
['Write the formula using named intermediate values if it contains more than one operation.', 'After each iteration, it should be clear what has already been accumulated and what remains to be processed.']
ANSWER
Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let km = Number(input);
let result = ((km) * (1000));
console.log(result);