Exercise Wednesday

Goal: Continue to practice testing with Jasmine/Karma and implement ES6 features along the way. You should use let and const instead of var, ES6 classes and modules, and template literals where needed. Test each part of your code in isolation and focus primarily on the business logic.

Warm Up

  • What is the difference between let and const? How are they an improvement over var?
  • What is Babel? What is a transpiler and why is it important to use one with ES6?
  • What new features are being considered for ES7? (Do a little research on your own to answer this question.)
  • Why would we use the class and module keyword in our code? What do they do?

Haiku Checker/Creator

A haiku is a poem that consists of three lines. The first has five syllables, the second has seven, and the third has five. Start by creating an application that checks whether a poem is in fact a haiku. If you have time, build out your application so that it can randomly generate haikus.

This project provides an excellent opportunity for BDD with Jasmine.

  • Your logic should verify that the poem has three lines.
  • Your logic should verify English syllable rules (and exceptions) one at a time. A quick Google search will provide information on English syllable rules.
  • If you successfully complete a Haiku checker, continue to build out your application to randomly generate haikus.

Make sure you test your application for each new rule you implement.

Build Your Own RPG

An RPG (Role Playing Game) is a game where players assume the roles of characters in a fictional world. Build and fully unit test the business logic for a Medieval Role Playing Game (or another genre that you prefer: sci-fi, cyberpunk, ‘80’s high school).

Logic could include the following:

  • Character creation: Use ES6 classes to generate different character types. Be creative with your character types… warriors, wizards, scientists, prom queen… whatever! Characters should have specific attributes. For instance, in a medieval RPG, characters might have strength and intelligence attributes among others. In an ‘80’s high school RPG, characters might have snark and charm.

  • Battle system: Many RPGs have a battle system so characters can fight monsters, though that could just as easily be a high school “battle” system where the prom queen has a dance-off with the theater aficionado. Determine conditions for “winning” a battle, whether that’s defeating monsters (with swords and spells doing damage), accumulating dance-off style points, or any other system you think of.

  • Level up: Determine a leveling system. Characters should be able to go from Level 1 to Level 2 and so on. Generally each level comes with new abilities. How do characters level up in your game? What attributes and powers do they gain? Does their strength go up or do they learn new spells?

  • Inventory: Characters should be able to have items that enhance their abilities. Maybe the Magic Armor increases their defense power or legwarmers increase their dance-off ability. Create a limit to the number of items a character can have. Characters should be able to add, drop, buy and sell items.

Feel free to build out your RPG as you see fit. The goal is to work with JavaScript logic, ES6 features, and TDD with Jasmine and Karma. You are not expected to have a functioning game in the browser. Instead, focus on testing and business logic!

Sudoku Solver/Creator - Challenging

Note: This is a complex problem that is best solved using a technique called backtracking. (Do your own research to find out more.) You aren’t expected to fully solve this problem. However, feel free to give it a go; the most important thing is that you thoroughly test all your business logic with Jasmine!

Create an application that solves and/or creates a Sudoku puzzle from scratch.

Peer Code Review

  • Does the app function as designed? Is it clearly presented?
  • Is the application fully tested with Jasmine and Karma? Are there any potential areas of the code that could be tested more fully?
  • Is the code clear and readable, following ES6 syntax with descriptive variable names? Are let and const used instead of var?
  • Does the project have a fully functioning Gulp file?