Giter Site home page Giter Site logo

recap_tasks_week-2's Introduction

Recap Week 2

Use the files in each task's corresponding folder to complete the following activities.

Remember to break down each task, make a plan before you code, and commit often using meaningful commit messages!

Note: You can click here to view the videos made by your fellow bootcampers this week as well!

Task 1

๐Ÿ‘‰ Write a function called makeLegend, which takes in a name (string) as its only argument. The function should return a new string which includes the name plus the words ' is now a legend.'.

  • For example, if the function was called with the name 'Chris', it should return the string 'Chris is now a legend.'.

๐Ÿ‘‰ Using the makeLegend function, the celebs array and a for loop, create a new array which includes ' is now a legend.' for each celebrity. Save this new array to the variable legendaryCelebs.

  • For example, if the celebs array was ["Chris", "Liz", "Alice"] to begin with, then legendaryCelebs would contain ["Chris is now a legend.", "Liz is now a legend.", "Alice is now a legend."]

๐Ÿ‘‰ Use another for loop to produce a new array of all of the celebrity names which start with a vowel, and store that new array in a new variable called vowelCelebs.

  • For example, if the celebs array was ["Chris", "Liz", "Alice"] to begin with, then vowelCelebs should contain ["Alice"] (as Alice is the only name that begins with a vowel).

Task 2

Click for hints if you get stuck

๐Ÿ‘‰ In the task-2 index.html, there is a p tag (with an id of count) that displays a count. Ensure the count displays 0 when the page loads and then, using setInterval, have it increment by 1 every second.

๐Ÿ‘‰ Stop the above interval from incrementing after 12 seconds have passed using the clearInterval function. So 12 should be the last count displayed on the page.

Task 3

Click for hints if you get stuck

For this task, you'll be using the Cat API to get image URLs.

๐Ÿ‘‰ Using fetch, get a random cat image URL using the API URL: https://api.thecatapi.com/v1/images/search

๐Ÿ‘‰ Once you have retrieved your image URL, display the image on the page using the img element provided (with id of cat-here). A different picture should be displayed every time you reload the page.

๐Ÿ‘‰ Using JavaScript, create a button element and add it to the page. Add an event listener to the button so that, when you click the button, a new image is displayed.

โญ Bonus

Use the task-4 folder for these.

๐Ÿ‘‰ On your HTML page, you will see an input field and an 'Add To List' button. Declare a new variable, importantThings, as an empty array. Using JavaScript, configure the website so that when you write something in the input field and click the Add To List button, a new item is added to the importantThings array.

๐Ÿ‘‰ As well as adding the item to the in-memory array, now display each added item in an li element within the ordered list.

๐Ÿ‘‰ Add a new label and input field element to your index.html file. This input field represents the priority value of your important thing, and should take in a number. Refactor your code so that, when you click your Add To List button, you add an object to your array, rather than a string value. For example: let importantThings = [{text: 'telephone mother', priority: 1}].

๐Ÿ‘‰ Add a new button to your site called Order List. When the button is clicked, reorder your list by priority.

โญ Bonus Bonus

๐ŸŽ‰ For the makeLegend function from Task 1, refactor it to check that you were handed a string - if you weren't, then return 'A legend requires a string'

โญ Bonus Bonus Bonus

๐ŸŽ‰ Style your pages with CSS!

Hints

Task 2

Think about using document.querySelector to access the p tag. How would you track the seconds?

Task 3

Remember fetch returns you a promise. You always await a promise. To use await, you must be in an async function.

You can set the src attribute of the img just like you would set the textContent of a p element

You already have a function which grabs new images and updates the image shown on the page. Link this to the button through addEventListener

recap_tasks_week-2's People

Contributors

crayola-eater avatar lizkaufman avatar cwissy avatar taosharma avatar mrbenbot avatar

Stargazers

Alex Platt avatar nicfheorais avatar Ibsa E Obsa avatar

Watchers

James Cloos avatar  avatar

recap_tasks_week-2's Issues

Run test script from project

  • Change so that NPM scripts can be run from the root level of the project. Easier and more consistent for autograding (as then don't have to maintain repo-specific logic).
  • Remove additional flags/options in test script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.