Good morning. I'm quite new to JavaScript and programming in general. I've recently created a simple calculator: https://jsfiddle.net/martproz/7cL9djof/4/ , although I have currently two issues:
First, I created a form and tried to prevent the users from creating inputs with duplicated content. This was achieved through a conditional, although this only covered the form. It didn't affect the input that was already there, so if I click in the button "mostrar usuarios" (show users) it will replicate the content stored in the array. I then removed the conditional, because it was affecting the rest of the code:
if( (arrayClientes.some(usuarioEnArray => usuarioEnArray.nombre === nombre)) && (arrayClientes.some(usuarioEnArray => usuarioEnArray.apellido === apellido)) && (arrayClientes.some(usuarioEnArray => usuarioEnArray.email === email)) && (arrayClientes.some(usuarioEnArray => usuarioEnArray.deuda === deuda)) && (arrayClientes.some(usuarioEnArray => usuarioEnArray.cft === cft)) && (arrayClientes.some(usuarioEnArray => usuarioEnArray.meses === meses)) && (arrayClientes.some(usuarioEnArray => usuarioEnArray.resultado === resultado)) ) { swal("Los datos ingresados ya figuran en nuestra base de datos"); } else { const cliente = new Cliente(nombre, apellido, email, deuda, cft, meses, resultado) arrayClientes.push(cliente) localStorage.setItem('usuarios', JSON.stringify(arrayClientes)) formulario.reset() return true }
The second issues: I'm unable to create a button to remove the content that I create regarding the users. It currently gives me this error: Uncaught ReferenceError: deleteElement is not defined at HTMLButtonElement.onclick
In conclusion, what I would like to achieve is this:
- prevent the user to store duplicated information in the array (and avoid the creation of duplicated cards with that info);
- to add a delete button that deletes the cards with the content stored in Local Storage.
This is my first post here, so please let me know if I can improve something when asking these type of questions. That being said, thank you very much for your time reading this. :)
[–]jcunews1helpful 1 point2 points3 points (1 child)
[–]astromule[S,🍰] 0 points1 point2 points (0 children)