The WebStorage manual entry notes:
ote WebStorage only stores strings. If you set a key to a number like 100, when you retrieve it back it will be a string. To convert it back, use the system expression int, e.g. int(WebStorage.LocalValue("score")).
So you're probably getting the value back from WebStorage as a string "2" rather than the number 2. Make sure you convert it back to a number when reading from WebStorage if it's supposed to be a number.