O'Reilly logo

Hands-On Full Stack Web Development with Aurelia by Erikson Haziz Murrugarra Sifuentes, Diego Jose Arguelles Rojas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Refactoring our code

At this point, everything is okay; we have our test and implementation written, the code is doing what we expect, and it seems that there's nothing left to do. But, as a good developer, we should look for ways to make our code more readable and reduce the lines of code. Also, the refactoring phase is used to change some weird variable names and, if possible, add comments to our code if needed.

Open your testing.js file and apply the following changes to make it more readable:

var assert = require('assert');function add(n1, n2) {  return n1 + n2;}assert.equal(add(5, 5), 10, "Should be 10");console.log("Test passed!!");

The first change is in the add function. As this is a simple addition operation, declaring a result variable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required