Functions
- MDN Readings:
- Videos by Steve Griffith
Free Code Camp Exercises
- Javascript basics: Exercises 47-55
- Start: Write Reusable JavaScript with Functions
- Stop: Stand in Line
In pairs, create a function that accepts a number as an argument in kilograms (kgs) and converts the number to pounds (lbs).
toPounds
that accepts a kilos
parameter.kilos
by 2.2 to convert to pounds.console.log
.Window.prompt()
method to define kilos
from user input.Don't forget the Pair Programming Dos and Don'ts.
One tricky aspect of Javascript is it will sometimes automatically convert one data type (i.e. a Number
) to another (a String
). This can lead to unexpected results.
Number()
function: for converting strings into numbers