O'Reilly logo

HTML5 Multimedia Development Cookbook by Lee Jordan, Dale Cruse

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Converting local storage strings to numbers using parseInt

In this recipe, we will take a string value from local storage and convert it into an integer so we can perform a mathematic operation on it by using parseInt.

Getting ready

We will be using Modernizr (http://www.modernizr.com) to detect if local storage is available, hosting it locally in a subfolder named "js". You will also need at least one recently updated browser.

How to do it...

Create the beginnings of a new html page up to the title tag as shown in the code block below:

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"> <title>Using numbers with local storage</title>

Next, add styles to specify the font-family, the text color of the h1 and h2 tag, and a background-color ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required