June 2018
Intermediate to advanced
348 pages
8h 19m
English
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 ...
Read now
Unlock full access