+ 1

Loops and Iteration

Please can someone tell me why this is iterating only once https://code.sololearn.com/WLQpJw32bC3Q/#html

10th May 2020, 2:05 AM
Prosper Emebo
Prosper Emebo - avatar
22 Réponses
+ 5
You don't have to say sorry for that. Please check the everything.js post I just shared. [...For local scripts, we put them before end tag of body, or as callback of load event of window object. This ensures the JavaScript script runs after the DOM exists...] Emebo Prosper The problem is that you're actually overwritting the innerHTML property instead of updating it. See Arb Rahim Badsa's answer.
10th May 2020, 2:57 AM
Kevin ★
+ 4
Your code expects a DOM element with "not" as id. You didn't provide it in your HTML. Add this in body: <div id="not"></div> Also remember that script from JS tag of CodePlayground are part of HTML head tag. https://www.sololearn.com/post/90825/?ref=app
10th May 2020, 2:35 AM
Kevin ★
10th May 2020, 3:01 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 2
I want it to do something like this, Please can you tell me why it is only iterating through the last one and why it is returning an error. https://code.sololearn.com/W0huh4GrhBS0/#js
10th May 2020, 3:09 AM
Prosper Emebo
Prosper Emebo - avatar
+ 1
Emebo Prosper I am not getting what you want to make. Do you want to store the usernames and passwords in the array?
10th May 2020, 3:13 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 1
Okay let, me clear things up : 1) User will enter a username 2) The programe will generate a password using the first and last name of the username. 3) Then you want to show the username and password on the screen. Is that so?
10th May 2020, 3:23 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 1
Not really let me give you an over view (1) new user creates account (2) Application stores it in local storage as an array inside an array called accounts (3) User logs in with user name, application fetches name from the dom and compares it with the one in the account array then adds it in local storage called current account. (3)When the user generates password he saves the password with a name.
10th May 2020, 3:30 AM
Prosper Emebo
Prosper Emebo - avatar
+ 1
(4) Then the application stores it as an array identifying the current then compares it with the one in local storage and stores as an array in local storage
10th May 2020, 3:33 AM
Prosper Emebo
Prosper Emebo - avatar
+ 1
(5) The question i asked is about the dashboard i want it to get the password from local storage based on the user name in the account array that is in the local storage
10th May 2020, 3:35 AM
Prosper Emebo
Prosper Emebo - avatar
+ 1
Thanks Arb Rahimb Badsa and kevin star i found the solution
10th May 2020, 3:52 AM
Prosper Emebo
Prosper Emebo - avatar
+ 1
Emebo Prosper This should solve your issue :)) You can check it even though you've solved. https://code.sololearn.com/W7Um4Avx19Fm/?ref=app
10th May 2020, 3:57 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 1
Thank you boss for everything you made my complicated code easy
10th May 2020, 4:02 AM
Prosper Emebo
Prosper Emebo - avatar
+ 1
That window.onload is the same thing as <body onload="myFunction()"></body> right
10th May 2020, 4:03 AM
Prosper Emebo
Prosper Emebo - avatar
0
I sorry im coding on my computer so when i was pasting i forgot
10th May 2020, 2:53 AM
Prosper Emebo
Prosper Emebo - avatar
0
I have modified that but it's still not working
10th May 2020, 2:54 AM
Prosper Emebo
Prosper Emebo - avatar
0
Please i don't understand. But as far as i know in the execution stack all functions are called first
10th May 2020, 3:00 AM
Prosper Emebo
Prosper Emebo - avatar
0
And on my computer the loop is only iterating once which is the last one, why??
10th May 2020, 3:02 AM
Prosper Emebo
Prosper Emebo - avatar
0
The first name and last name is what will be used to recognise the passwords of the user
10th May 2020, 3:17 AM
Prosper Emebo
Prosper Emebo - avatar
0
Then in the JavaScript where it s inputting as name that will be what the user will use to recognise the password he generated
10th May 2020, 3:19 AM
Prosper Emebo
Prosper Emebo - avatar
0
So in that particular function the first name and last name is not needed that is why i removed it
10th May 2020, 3:20 AM
Prosper Emebo
Prosper Emebo - avatar