Welcome to the tenth Easy JavaScript Tutorial, Beginner JavaScript Tutorial, part of Easy Programming! This tutorial covers Type Coercion. What is type coercion? Why should you use it? Learn about it in this video!
I mentioned in the intro video that JavaScript is a weakly typed language. It means that the variable type can be changed without any major issues.
To coerce a string to become a number, we can use either parseInt or parseFloat, the difference being that parseFloat will accept decimals or floating points, whereas parseInt will only take the integer.
To fork the fiddle and follow along: https://jsfiddle.net/easyjs/ex71ghux/
Remember to checkout the Resources section below for associated downloadable content, JSFiddle links, and other resources. Watch the video and follow along!