diff --git a/ex1.js b/ex1.js index ac1a32b..35672d0 100644 --- a/ex1.js +++ b/ex1.js @@ -2,18 +2,4 @@ var array = [1, 2, 3, 4, 5, 6]; -array = filter(array, function (each) { - return each % 2 === 0; -}); - console.log('Even numbers: ' + array); - -function filter(array, predicate) { - var result = []; - for (var i = 0; i < array.length; i++) { - if (predicate(array[i])) { - result.push(array[i]); - } - } - return result; -} \ No newline at end of file diff --git a/ex2.js b/ex2.js index 9a95b14..1e0cd63 100644 --- a/ex2.js +++ b/ex2.js @@ -2,11 +2,5 @@ var array = [1, 2, 3, 4, 5, 6]; -array = array.filter(function (each) { - return each % 2 === 0; -}).map(function (each) { - return each * each; -}); - console.log('Even numbers squared: ' + array); diff --git a/ex3.js b/ex3.js index 05898c0..e4410d1 100644 --- a/ex3.js +++ b/ex3.js @@ -9,11 +9,5 @@ var array = [ { id: 6, selected: false } ]; -array = array.filter(function (each) { - return each.selected; -}).map(function (each) { - return each.id; -}); - console.log('Ids of selected objects: ' + array); diff --git a/ex4.js b/ex4.js index 697cb47..eb109ab 100644 --- a/ex4.js +++ b/ex4.js @@ -1,20 +1,2 @@ 'use strict'; -function Person(name) { - this.name = name; -} - -Person.prototype.getName = function () { - return this.name; -}; - -Person.prototype.setName = function (name) { - return this.name = name; -}; - -var person = new Person('Jack'); -var person2 = new Person('Jack'); - -console.log(person.getName()); -console.log(Object.keys(person)); -console.log(Object.keys(person.__proto__)); \ No newline at end of file diff --git a/ex5.js b/ex5.js index 1543ded..b2084d4 100644 --- a/ex5.js +++ b/ex5.js @@ -1,12 +1,6 @@ 'use strict'; -factorial(5, function (res) { - console.log('res: ' + res); -}); - - - function factorial(n, callback) { if (n < 0) { throw 'illegal argument' diff --git a/ex6.js b/ex6.js index 36e2388..bf9c8ea 100644 --- a/ex6.js +++ b/ex6.js @@ -3,29 +3,19 @@ var request = require("request"); get('/api/persons/2948', function(data) { - var code = data.code; - var name = data.name; - - get('/api/health-insurance/' + code, function(data) { - var isInsured = data.isInsured; - - get('/api/tax-debt/' + code, function(data) { - - var debt = data.debt; - - var person = { - name : name, - isInsured: isInsured, - taxDebt: debt - }; - - console.log(person); - }); - }); - + console.log(data); }); + + + + + + + + + // helper function function get(url, cb) { request('http://localhost:3000' + url, function(error, response, body) {