0
Good afternoon! I am creating a Javascript application using localstorage for data storage. The application is simple, I’m just practicing some concepts, and it involves some personal data and a field composed of 10 numbers as unique identification, generated when registering. What I’m struggling to create is a function that looks for this unique identification amid data saved in localstorage.
function pesquisarAluno(){
let matriculas = Array()
let id = localStorage.getItem('id')
for(let i = 1; i <= id; i++){
let recuperar_matricula = JSON.parse(localStorage.getItem(i))
if(recuperar_matricula === null){
continue
}
recuperar_matricula.id = i
matriculas.push(recuperar_matricula)
}
console.log(matriculas)
}
And what is the difficulty? What is the structure of the saved data?
– Costamilam
At the moment I am able to pass the data to an array, however I am not able to recover any registration based on the registration. Basically it is to recover a record through this identification.
– Caio 775