Skip to content

Instantly share code, notes, and snippets.

@iAmWillShepherd
Last active October 5, 2017 18:49
Show Gist options
  • Save iAmWillShepherd/59a4b3ec52d17c7a597576667a7f6d99 to your computer and use it in GitHub Desktop.
Save iAmWillShepherd/59a4b3ec52d17c7a597576667a7f6d99 to your computer and use it in GitHub Desktop.

Week 4.2 Quiz

This quiz is meant to evaluate your knowledge of JavaScript

  • Types
  • Conditionals
  • Loops
  • Variables and Constants
  • Functions
  • and Operators

Moreover, is an example of what you may be expected to code later in the course and out in life.

Please answer all of the question in Questions and implement everything in Code. An object, obj, is defined for you. All questions and coding problems must make use of that object.

If you finish those early, please move on to the Bonus and Challenge sections. These are meant to test your ability to solve basic problems using all the things you have learned along with a few things you may not have learned.

You have 10 mins to complete...

var obj = {
  movies: [
    'The Lion King',
    'Aladdin',
    'The Little Mermaid',
    'The Fox and the Hound',
    'Beauty and the Beast',
    'Mulan',
    'Pinocchio',
    'Cinderelle',
    'The Princess and the Frog',
    'Pocahontas',
  ],
  reviews: [
    function(movie) {
      return movie + ' is extremely funny!'
    },
    function(movie) {
      return movie + ' is the best movie of all time!'
    },
    function(movie1, movie2) {
      return movie1 + ' came out before ' + movie2 + '.'
    },
  ],
  favorites: [
    {
      'is CGI': [
        {
          frozen: {
            'Main Characters': [
              'Elsa',
              'Anna',
              'Olaf',
              'Kristoff',
              'Hans',
              'Pabbie',
              'Duke of Weselton',
            ],
            songs: [
              {
                title: 'For the First Time in Forever',
                length: '3:45',
              },
              {
                title: 'Let it Go',
                length: '3:45',
              },
              {
                title: 'Do You Want to Build a Snowman',
                length: '2:37',
              },
            ],
          },
        },
      ],
    },
  ],
  studio: 'Disney',
  animatedFeatures: 56,
  isMovieTitleLonger: function(movie1, movie2) {
    return movie1.length > movie2.length
  },
  releases: {
    '70s': [
      'The Aristocats',
      'Robin Hood',
      'The Many Adventures of Winnie the Poo',
      'The Rescuers',
    ],
    '80s': 6,
    '90s': 18,
    '2000s': 24,
  },
  compareMovies: function(movie1) {
    return function(movie) {
      const review = obj.reviews[obj.reviews.length + -1 * obj.reviews.length](movie1)

      return review + ' but ' + obj.reviews[obj.reviews.length - 1](movie1, movie)
    }
  },
}

Questions

  1. What does compareMovies return?
  2. What type is songs?

Code

  1. Write the statement that returns the number of releases for the 90s.
  2. Write the statement that returns "Pocahontas came out before The Princess and the Frog"; kudos for using a function

Bonus

  1. Write a function, frozenCharactersWithTwoOrMoreVowelsInName, that prints all the characters in Frozen whose name contains 2 vowels or more
  2. Write a function, countCharacters, that returns the character count of all movie titles
  3. Write a function, longestMovieTitle, that returns the longest movie title; use the isMovieTitleLonger key/property

Challenge

  1. Write a function, lengthOfFrozenSongsInSeconds, that returns the length of all the songs in Frozen in seconds
  2. write a function, mostProductiveYear, that returns the most productive year for releases; productive is defined by amount of movies released

Answers to Questions and solutions to Code will be reviewed after the quiz.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment