Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This file is a TypeScript React file, which allows it to use normal TypeScript as well as HTML tags. Read through the file and try to get a general understanding (don’t worry if it doesn’t make any sense, our React Learning Session is next Monday). In this file, your goal is to find the "names" array and add a new entry containing your name and favorite color to the end of it!

Panel
panelIconIdatlassian-info
panelIcon:info:
bgColor#F4F5F7

TypeScript is built off of JavaScript, which uses JSON. Here’s a 1 minute video explaining how JSON works. Here’s a quick article explaining the basics. In TypeScript, we are able to add a type annotation to a JSON object to enforce the right type. A declaration of a variable might look like this:

...

const cat: { name: string; age: number } = { name:

...

'Lucky', age:

...

13 };

In this example, const means that this is a constant and won’t be reassigned. cat is the name of the variable. The : after cat and the JSON after it is a TypeScript feature that tells us the type of cat. In this case, cat is an object with a key name that is a string and a key age that is a number. Finally, we assign cat to a value using =. We make it an object where the name is the string Lucky and the age is 13. Try putting the above line in the file we’re working on and change age to be 'five'. Do you get an error? What does it say and Why?

Using the above information, you should be able to add another entry to the names array in the file.

Once you’re done, save the file. To view your changes, go to your terminal and run yarn install and then yarn start. This will start the website at localhost:3000. Go to your browser and enter the url localhost:3000/credits. If you get stuck along the way make sure to ask any questions in slack!

...

Committing Your Code

Once you’ve completed your ticket and are ready to submit what you have for review, go back into your command line, make sure you are still on the right branch by running git branch, and run the command git add . which will save all the changes you've made, then run git commit -m '#YourIssueNumber Added my name to credits' Once you've committed your work, you must push it to the remote site by entering git push.

...