When you store it in memory, it’s converting it to a string instead of a number. So even though the console is printing it as 2 when you get it back from wix-storage, it’s really “2”. Try wrapping your session . getItem ( “mpi” ) into parseInt( session . getItem ( “mpi” )), to convert it to a positive integer.
If you want to add some error handling as well, for your own sanity
, then in the line right above this you can also add:
if(isNaN(session.getItem("mpi")) { throw Error("The value returned is not a valid number" }
Hope this helps, in adding to Russian’s excellent answers.