Hi ,
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
Hi ,
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
Also, for a cleaner Codepen, you can fork this one:
https://blog.codepen.io/documentation/forks/
โ
Schalk
Staff Community Manager - MDN Web Docs
You can also find starting Codepens for Loops 2 and Loops 3
โ
Schalk
Staff Community Manager - MDN Web Docs
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
This is not really important but, from a naming perspective, it might read more natural (maybe it is just me ) to use the following naming format: #naming-is-hard
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
@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( ) . 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
Great work @Dinesh_Sake!
That works great! Well done, @Dinesh_Sake