Week 5-finally caught up? not even close :(

work from week 5 and I’m officially caught up……. I think…….

Tutorials
object-examples.html
/ object-examples.js

movie-db-exercise.html / movie-db-exercise.js

Problem sets

week 5

Blog question 

Link to an example dynamic web page that likely pulls data from a database to build the site – any social media site, newspaper, blog, etc. Take a screenshot of a typical “post” and propose an object data structure to store all the elements of the post. Use the Enlighter code embed tool to include your proposed object design in a code sample.

This is a typical Facebook post when you look on someone’s page.

let post = {
    user_avatar: "ComicBook.jpg",
    user_name: "ComicBook.com",
    user_security: "public", //Used to tell if all post is public, private, etc...
    content: {
        date: "march 31",
        time: "5:35pm",
        time_zone: "GMT", //Used for different time zone conversion
        text: "BREAKING: Chris Meloni to star in Law & Order: SVU spinoff!",
        media: "",
        feedback: { //This is right under the media.
            like1: function () {},
            like2: function () {},
            like3: function () {},
            comments: function () {},
            shares: function () {},
        },
        links: { //This is the last section which allows user to like, comment, or share the post.
            like: function () {},
            comment: function () {},
            share: function () {},
        }
    }

Join the Conversation

1 Comment

  1. Very good work on your functions! And I think you’re getting a good sense of how to work through the object data structure. You and many other students did a similar thing with the list of ctCoursesTaken(arr) function.

    function ctCourseCount(studarr) {
    studarr.forEach(function(student) {
         console.log(`${student[i].name} has taken ${student.coursesTaken}`);
    }) 
    }    
    

    This works but student.coursesTaken returns the array of string values not a string. Effectively your’re going to see your array syntax – brackets and quotes around each value – instead of a nice readable sentence. The solution is to use an array method like Array.join() to “stringify” your array. For example this implementation would work:

    ${student.coursesTaken.join(', ')}
    //returns "course, course, course, course"
    
    //better than the current
    ${student.coursesTaken}
    //returns "["course", "course", "course", "course"]"
    
    
Leave a comment

Your email address will not be published. Required fields are marked *

css.php