[WEEK #5] – 12 JavaScript Basics – Objects + Problem Set + Blog Question


Hello. This is just another week. Not a lot of tutorial files we have to upload ( I like that). Objects was fun to learn. I felt I learned a very important topic that is used throughout JavaScript everywhere. I added an extra tutorial files because video 119 was a separate file created by colt. Most of the code in the files are random stuff he explains and I write it down.

Tutorials


Problem Set

  • students.html / students.js
    1. ctCourseCount(students);
    2. ctCourseCountforEach(students);
    3. isNotEnrolled(students);
    4. coursesTaken(students);

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. The only part I did not understand was where to put the section where there are 3 emoji’s, comments and share. Those 3 parts are on the same section, different from the 3 links at the bottom.

let post = {
    user_avatar: "osrs.jpg",
    user_name: "Old School Runescape",
    user_security: "public", //Used to tell if all post is public, private, etc...
    content: {
        date: "February 6",
        time: "2:01pm",
        time_zone: "GMT", //Used for different time zone conversion
        text: "The Nightmare has awoken!",
        media: "osrs-nightmare.mp4",
        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. I love that you created a bunch of methods for your data structure!!! Great work!

    And as far as your problem sets go the only issue I saw was with the final function:

    //`${student.name} has taken ${student.coursesTaken}`
    //returns 'Disksha Dohman has taken ["CT 101", "CT 210", "CT 137", "CT 205"]'
    //add a Array.join(separator) method to return a string comma separated values.
    //${student.coursesTaken.join(", ")} would work

    You could also loop through the values of the array and concatenate them to the string, but a little Google-foo leads to array to string methods like join().

Leave a comment

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

css.php