Giter Site home page Giter Site logo

node-debugger-lab-g-416's Introduction

Debug a Script Lab

Objectives

  1. Use Node built-in debugger by putting statements into a given script to find a problem by using debugger
  2. Launch debugger
  3. Fix the script

Introduction

You've been hired by a major national bank to fix some of their account creation code. They had some bad developers in the past that left some bugs in the code. Your job is to fix all the issues and get the code functional again.

In this lab, you'll debug a Node script which has an issue.

Instructions

  1. Open account.js then launch it from a command line with node account.
  2. Notice some issues (there a few of them)
  3. Put some debugger statements in account.js
  4. Launch in debug mode with node debug account
  5. Track issue
  6. Fix the file. Hint: there are 3 issues to fix.
  7. Run test with npm test

The fixed script should output the following:

Account before opening:  { balance: 0, name: 'Azat Mardan', checking: '1' }
New balance after signup bonus is 250
Account after opening:  { balance: 1250,
  name: 'Azat Mardan',
  checking: '1',
  type: 'checking' }

View node-debugger-lab on Learn.co and start learning to code for free.

node-debugger-lab-g-416's People

Contributors

azat-co avatar victhevenot avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-debugger-lab-g-416's Issues

Mismatch between lesson instructions and test suite/solution code

The lesson instructions state:

The fixed script should output the following:

Account before opening:  { balance: 0, name: 'Azat Mardan', checking: '1' }
New balance after signup bonus is 250
Account after opening:  { balance: 1250,
  name: 'Azat Mardan',
  checking: '1',
  type: 'checking' }

But the tests are expecting this (note the difference between 'Account before opening' balance):

var expectedOutput = { 'Account before opening':
   { balance: 1250,
     name: 'Azat Mardan',
     checking: '1',
     type: 'checking' },
 ...

I think it makes more sense to have the account set up with an opening balance of 0, so the lesson solution should perhaps be changed in light of that. I have come up with this code (spoiler alert!):

module.exports= function () {
  var output = {}
  var customerAccount = {
    balance: 0,
    name: 'Azat Mardan',
    checking: '1'
  }

  var setAccountType = function () {
    if (customerAccount.checking == 1) {
      customerAccount.type = 'checking'
    } else {
      customerAccount.type = 'savings'
    }
    output['Account before opening'] = customerAccount
    return customerAccount
  }

  var signupBonus = 250,
    deposit = 1000

  var newAccount =  Object.assign({}, setAccountType())

  var openAccount = function(newAccount, deposit) {
    newAccount.balance += signupBonus
    output['New balance after signup bonus is '] = newAccount.balance
    newAccount.balance += deposit
    output['Account after opening'] = newAccount
  }
  openAccount(newAccount, deposit)
  return output
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.