Assessment wanted for Loops skill test by Dinesh

Hi :wave:,
I have recently finished the Loops skill test, and I want a review for my test codes. Here are my code link and task link.

Thank you in Advance,
Dinesh

Hey there @Dinesh_Sake!

Nice work! I started having a look at the first of your loop skill tests. I notice that you use innerHTML to add the list items. Using innerHTML is generally not the best way to do this as it can open you up to security vulnerabilities.

Can you think of another way to solve this challenge without using innerHTML?

โ€“
Schalk
Staff Community Manager - MDN Web Docs

1 Like

Also, for a cleaner Codepen, you can fork this one:
https://blog.codepen.io/documentation/forks/

โ€“
Schalk
Staff Community Manager - MDN Web Docs

1 Like

You can also find starting Codepens for Loops 2 and Loops 3

โ€“
Schalk
Staff Community Manager - MDN Web Docs

1 Like

Hey @Dinesh_Sake, those are essentially the same as the files linked to from the assessment page but in Codepen form.

Here is a quick video that will help explain the process.

โ€“
Schalk
Staff Community Manager - MDN Web Docs

@Dinesh_Sake Great work! In Loop 2, can you think of another way to determine whether a match was found in the loop other than checking the contents of the paragraph?

Hint: boolean :wink:

This is not really important but, from a naming perspective, it might read more natural (maybe it is just me :slight_smile: ) to use the following naming format: #naming-is-hard :slight_smile:


for (const entry of phonebook) {
    if (name === entry.name) {
      para.textContent = `${entry.name}'s number is ${entry.number}.`
      break;
    }
}

Keep up the great work!

โ€“
Schalk
Staff Community Manager - MDN Web Docs

1 Like

@Dinesh_Sake, for Loop 3, have a look at your while loop. Currently, it will always go into the else part of the condition. Can you see why this is the case?

โ€“
Schalk
Staff Community Manager - MDN Web Docs

No Sir, Iโ€™m unable to think of any other way, but Iโ€™ve tried something which might be the answer to your question(:crossed_fingers: ) . Also Iโ€™ve made the changes suggested by you.
Thank you for your help,
Dinesh

No Sir, I donโ€™t know how to add lists or other elements in any other way other than innerHTML. Please enlighten me on how to do it otherwise.

Actually I have no idea what youโ€™re talking about sir. While solving that problem I threw whatever piece of code that worked. So please tell me how do I tackle the problem.

I Have done some changes to Loops 3 task. Please check whether it is correct or not.

With regards,
Dinesh

1 Like

Great work @Dinesh_Sake!

1 Like

That works great! Well done, @Dinesh_Sake :tada:

1 Like