Code Challenge #13: Going From ES5 to ES6

By William Imoh

Previously on the Scotch Code Challenge, we have solved challenges involving String, Object and Array Manipulation with functional programming patterns. How about we touch up the script in ES6!

This week on the Code Challenge we will convert ES5 code to even better and shorter code using ES6 Syntax.

ES6 is an update of JavaScrpt which shipped with tons of amazing features to make write JavaScript painless and bug-free! Previously we all used ES5, pretty decent but more prone to leaks and more arduous to write.

The Challenge

In this challenge, we are required to re-write simple ES5 code to ES6. This challenge focuses on the most common ES6 features utilized. Including:

  • Arrow Functions
  • Enhanced Object Literals
  • Template Literals
  • Destructuring
  • Spread Operation.

Five challenges are listed in the boilerplate codepen which requires a re-write of the ES5 code already written.

Find the sample codepen here: https://codepen.io/Chuloo/pen/xadjjO

Fork this Codepen to Get Started

https://codepen.io/Chuloo/pen/xadjjO

Requirement

The requirement is simple, re-write the code using ES6 syntax. Also, each function declared should pass when called.

Goals for this Challenge

On completion of this challenge, you should be able to:

  • Understand basic ES6 syntax.
  • Write more readable code.
  • Utilize fewer lines in writing clean code.

Resources

Feeling stuck? Here’s this handy post by Josh Marinacci on 5 Things you can Use in ES6 Today. Also, feel free to get started quickly with the sample codepen created here. https://codepen.io/Chuloo/pen/xadjjO

Community

On completion of the challenge, you can showcase it to receive reviews on the awesome work done. Here’s how:

  • Post in on Twitter using the hashtag #ScotchChallenge and we’ll be sure to see it!
  • Improve your writing skills by writing a blog post about it and we’ll feature it in our community posts!
  • Post your completed challenge in the comment section of this post.
  • Join the chatter on Spectrum and showcase your submission!

Also, complete this challenge to get 5 entries to the Scotch Launch Giveaway, let’s celebrate the brand new Scotch v8 launch together!

Solution

The solution to this challenge will be posted on Monday! Happy coding!

Source:: scotch.io