How to check if duplicate key exists in local -storage in ionic


I have stored data in local storage,with key and values,

key is account name…
When a user creates a new account ,i want to put a check if the same key exists or not …

how should i achieve this,if the same key exists,then alert should be created else not…

I tried using the get item function ,but everytime it returns null,wheteer or not the key exists…


this does not works for me…


Duplicate at How to check if key exists in local-storage