Responsive Web Design Coursera Quiz Answers

Week 4: Responsive Web Design Coursera Quiz Answers

Quiz 1: JavaScript arrays

Q1. Why are arrays useful?

  • They can store very long pieces of text
  • They can store lots of individual bits of data

Q2. Which of these is a correctly defined array?

  • 1 [‘one’, 2, 3.0]
  • 1 {‘one’, ‘two’, ‘three’}

Q3. What is the first element of an array called “a”?

  • 1 a[0]
  • 1

Quiz 2: Storing objects in arrays and displaying them with a template

Q1. To use a template with an array you need to:

  • Create lots of templates, one for each template in an array.
  • Use a single template but instantiate it separately with each item in the array.
  • Use a single template and instantiate it once with the whole array

Q2. Did you spot the error in my slides? It was with this code.

12345678

  • The last template expression should be {{#each}} not {{/each}}
  • The div is not closed

Q3. Everything inside the {{#each}} {{/each}} expression is

  • Repeated once for each element in the array
  • Rendered a single time but with all the data in the array

Quiz 3: Dynamically displaying single images from an array

Q1. How do you access individual elements of an array?

  • By number
  • By name

Q2. What does {{@index}} do?

  • Get a member variable called index
  • Get the number of the current item in the array

Q3. What is data-id?

  • The identification number of an element of a data array
  • A special “data” attribute that allows us to add extra data to an HTML tag

Quiz 4: Implementing a search function

Q1. Why do keypress events represent keyboard keys as numbers and not letters?

  • You can’t represent a letter directly on a computer
  • Some keyboard keys can’t be represented as letters

Q2. Why do you need to pass a function to filter an array?

  • The function takes an individual element of the array and figures out whether it should be kept or not
  • The function steps through every element of the array in turn

Q3. Filter changes your array so you need to save a backup

  • TRUE
  • FALSE

Quiz 5: Data structure for a complete image gallery

Q1. You cannot have an array as a member variable of an object

  • TRUE
  • FALSE

Q2. You should always represent a photo album as just an array, not an object, because it is just a bunch of photos.

  • TRUE
  • FALSE

Q3. What data type did I use to represent the name of the photo album?

  • An array
  • An object
  • A string (text)

Quiz 6: Writing the templates for the gallery

Q1. To a hierarchical data structure, like a photo gallery that contains many albums, each of which contains many photos, …

  • You must use a different template for each level: one for albums and one for photos
  • You can include both levels (albums and photos) in the same template

Q2. What does {{photos.length}} do?

  • Renders the “length” member variable of the array “photos”
  • Takes two member variables “photos” and “length and joins them together with a dot.

Q3. What does {{#if @first}} do?

  • Gets the first element of the current array, if there is one
  • Only renders the following template code if the current element is the first one in the array

Quiz 7: Building a full gallery app summary quiz

Q1. What is an array?

  • A JavaScript data structure that can store many items and can access them by a number
  • A JavaScript data structure that can store many items and can access them by a name
  • A template where template expressions access data items by a number
  • A template where template expressions access data items by a name

Q2. If you were building a social media site, which of the following would you represent as an array? (select all that apply)

  • A person’s name
  • A person’s friends list
  • A person’s timeline
  • A person’s profile

Q3. What is wrong with this array definition?

1var myArray = [“one”, 2, 3.0, [4, 5, “six”];

  • It should have curly brackets {} instead of square brackets []
  • It has the wrong number of commas (,)
  • It has the wrong number of close brackets (])
  • You cannot have an array inside another array

Q4. What does this code do?

1$(“#myButton”).click();

  • Changes which function is called when the element with id “myButton” is clicked
  • Stops any function being called when the element with id “myButton” is clicked
  • Calls the function that would normally be called when the element with id “myButton” is clicked
  • Changes the style of the element with id “myButton” to look like it does when it is clicked.

Q5. What does the template expression {{#each length}} do?

  • Show the member variable “length” of the object “each”
  • Show the number of items in the array “each”
  • Repeat the following code for all items in the array “length”
  • Show the member variable “each” followed by the member variable “length”

Q6. What is wrong with this template definition?

123

 {{#each things}}

  • {{name}}
  • There is an expression {{/each}} missing
  • the
    • Instead of {{name}} it should be {{things.name}}
    • Instead of {{#each things}} it should be {{#each}} {{things}}

      Q7. Which template will correctly display all of this data?

      123456789 var mydata = {name : "me",pets : [ {type : "cat",favouritebit : "whiskers"},{type : "dog",favouritebit : "ears"}]}

    • 1234

      {{name}}

      {{pets}}

    • 1234567
      {{#each pets}}

       

      {{name}}

      {{type}}

      {{favouritebit}}

      {{/each}}

    • 1234567

      {{name}}

      {{pets[0].type}}

      {{pets[0].favouritebit}}

      {{pets[1].type}}

      {{pets[1].favouritebit}}

    • 1234567
      {{name}}

      {{#each pets}}

      {{type}}

      {{favouritebit}}

      {{/each}}

      Q8. When you instantiate this template with an object in which “pets” is an array with many members, which HTML tags only appear once in the final output?

      12345678

       

       

        

      About me

        

      {{name}}

        {{#each pets}}

        

      {{type}}

        

      {{favouritebit}}

        {{/each}}

       

      (select all that apply)

    • 1
    • 1
    • 1
    • 1

      Q9. What HTML does this template produce when you instantiate it with the data below?

      15

      }]}

    • 123456

       

        

      The nations favorite short stories about Aardvarks

        

      George the killer Aardvark

      </div id=”contents”>

        

      Clarice Davies

      Aardvarks of the Carribean

       

        David Clarence

    • 123456

       

        

      The nations favorite short stories about Aardvarks

        

      George the killer Aardvark

        

      Aardvarks of the Carribean

      Clarice Davies

      David Clarence

    • 1234

       

        

      The nations favorite short stories about Aardvarks

        

      Clarice Davies

      David Clarence

    • 1234567

       

        

      The nations favorite short stories about Aardvarks

        

      George the killer Aardvark

        

      Clarice Davies

        

      Aardvarks of the Carribean

        

      David Clarence

      Q10. What HTML does this template produce when you instantiate it with the data below?

      1234567891011121314151617181920

      {{category}}

      {{#each products}}

      {{name}} {{@index}}

      {{/each}}

      var toys = {category : "toys",index : "3462",products : [ {name : "train set",index : "3"},{name : "dolls house",index : "2"},{name : "building bricks",index : "1"} ]}6

       

    • 123456

       

        

      toys

        

      train set 0

        

      dolls house 1

        

      building bricks 2

    • 123456

       

        

      toys

        

      train set 3462

        

      dolls house 3462

        

      building bricks 3462

    • 123456

       

        

      toys

        

      train set 3

        

      dolls house 2

        

      building bricks 1

      Conclusion:

      I hope this Responsive Web Design Coursera Quiz Answers would be useful for you to learn something new from the Course. If it helped you, don’t forget to bookmark our site for more Quiz Answers.

      This course is intended for audiences of all experiences who are interested in learning about new skills in a business context; there are no prerequisite courses.

Leave a Reply

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