malkitbenning / Coursework-Planner

Your coursework planner
0 stars 0 forks source link

[TECH ED] Review solutions for TV show project #32

Open malkitbenning opened 1 year ago

malkitbenning commented 1 year ago

From Module-React created by Dedekind561: CodeYourFuture/Module-React#14

Link to the coursework

https://github.com/CodeYourFuture/TV-Show-DOM-Project-Solution

Why are we doing this?

At the end of this week, be sure to review the solutions for last week's coursework. You should return to the TV Show project again at the end of React.

Maximum time in hours

1

How to get help

No response

How to submit

n/a

How to review

No response

Anything else?

No response

malkitbenning commented 1 year ago
    container.appendChild(card);
    card.appendChild(h1);
    card.appendChild(img);
    card.appendChild(p);

The developer did all the createElement and adding classes etc somewhere else but they grouped all the "appending" in one bit of code. This is a great idea! This shows what your structure will look like with one quick look at the code, instead of having to look through several lines before figuring out the layout. I shall do this in future!

malkitbenning commented 1 year ago

I noticed several uses of helper functions, that were small, but used often - especially in function chaining. I shall try to adopt this approach more.

Also, it would be good to understand what this does... function contains(inspectStr, targetStr) { return inspectStr && targetStr && -1 !== inspectStr.toLowerCase().indexOf(targetStr.toLowerCase()); }

Interesting way to fill in gaps when images don't exist in API response. img.setAttribute( "src", show.image ? show.image.medium : "https://placekitten.com/300/200" );