diff --git a/array_map_parseint/README.md b/array_map_parseint/README.md index 419984a..a3d2668 100644 --- a/array_map_parseint/README.md +++ b/array_map_parseint/README.md @@ -45,7 +45,7 @@ When we execute the previous code, this is that it's executed when we run the Sn * parseInt(1000000, 6) => 46656 ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- diff --git a/autoexecute/README.md b/autoexecute/README.md index a78c458..4231dfe 100644 --- a/autoexecute/README.md +++ b/autoexecute/README.md @@ -20,7 +20,7 @@ SyntaxError: Unexpected token ) ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -38,7 +38,7 @@ undefined ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -57,7 +57,7 @@ The value of testValue is undefined because the function has not been autoexecut ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- diff --git a/banking/README.md b/banking/README.md index be7f030..f84f56b 100644 --- a/banking/README.md +++ b/banking/README.md @@ -22,18 +22,18 @@ var yourChange = calculateChange(); --- -What returns calculateAmountOfStockOptions ? Input the number value. +What returns calculateAmountOfStockOptions ? ```js -var stockOptions = ; + ``` ```js -var stockOptions = 1.94392523364486; +1.94392523364486 ``` ```js -assert(stockOptions == 1.94392523364486); +__match_answer_and_solution__ ``` --- @@ -43,15 +43,15 @@ assert(stockOptions == 1.94392523364486); What is the value of calculateChange ? Input the number value. ```js -var change = ; + ``` ```js -var change = 10.100000000000001; +10.100000000000001 ``` ```js -assert(change == 10.100000000000001); +__match_answer_and_solution__ ``` --- @@ -65,11 +65,11 @@ Why? ``` ```js -'Javascript has several problems operating with floating point, this is one of the causes that it should not be to operate with floats.' +Javascript has several problems operating with floating point, this is one of the causes that it should not be to operate with floats. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- diff --git a/conditionals_functions/README.md b/conditionals_functions/README.md index 56e9fc4..5e40652 100644 --- a/conditionals_functions/README.md +++ b/conditionals_functions/README.md @@ -65,6 +65,6 @@ The execution of Snippet 3 shows "That's true" because when the code has been ev ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- diff --git a/delete/README.md b/delete/README.md index ef1c5c4..b71d901 100644 --- a/delete/README.md +++ b/delete/README.md @@ -57,7 +57,7 @@ Why **#1: John** is logged? John is logged because name is a global variable and global variables can't be deleted. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -73,7 +73,7 @@ Why **#2: undefined** is logged? undefined is logged because we have deleted the name property of obj, properties or members of objects can be deleted excluding the properties or members of the global object. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -89,7 +89,7 @@ Why **#3: function toString() { [native code] }** is logged? function toString() { [native code] } is logged because toString is an inherited method from Object and inherited methods or members can't be deleted. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -105,7 +105,7 @@ Why **#4: animal** is logged? animal is logged because we have deleted the own mammal.name property but the inherited property is shown. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- \ No newline at end of file diff --git a/even_odd/README.md b/even_odd/README.md index 0584aa2..7d4074f 100644 --- a/even_odd/README.md +++ b/even_odd/README.md @@ -57,7 +57,7 @@ Number.MAX_VALUE can't be handled properly by Javascript to work with it in oper ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- diff --git a/fooling_around_boolean/README.md b/fooling_around_boolean/README.md index ae14e0c..1660ec8 100644 --- a/fooling_around_boolean/README.md +++ b/fooling_around_boolean/README.md @@ -22,7 +22,7 @@ Why does xor resolves in an unexpected manner? Because this is not false, this inside the function is the complete object and it evaluates to true when it's converted to true the same way that !!{} is true. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- diff --git a/fooling_around_boolean_2/README.md b/fooling_around_boolean_2/README.md index 036438b..be4928c 100644 --- a/fooling_around_boolean_2/README.md +++ b/fooling_around_boolean_2/README.md @@ -39,6 +39,6 @@ Why does calling the previous statement returns false? You have to be careful when using |= because when it's used to perform a test besides an object it will not modify the original value, then it remains to be zero. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- \ No newline at end of file diff --git a/ghost_array/README.md b/ghost_array/README.md index 736e63b..87bdb1a 100644 --- a/ghost_array/README.md +++ b/ghost_array/README.md @@ -13,13 +13,13 @@ console.log(arr.length); What is the result of execute "Snippet 1" code? ```js -var result = ; + ``` ```js -var result = 1000; +1000 ``` ```js -assert(result === 1000); +__match_answer_and_solution__ ``` --- @@ -34,13 +34,13 @@ console.log(arr.length); What is the result of execute "Snippet 2" code? ```js -var result = ; + ``` ```js -var result = 0; +0 ``` ```js -assert(result === 0); +__match_answer_and_solution__ ``` --- @@ -54,7 +54,7 @@ Why? Because 4294967295 overflows the max number of elements that could be handled by Javascript in Arrays. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -70,13 +70,13 @@ console.log(arr[4294967295]); What is the result of execute "Snippet 3" code? ```js -var result = ; + ``` ```js -var result = "james"; +"james" ``` ```js -assert(result === "james"); +__match_answer_and_solution__ ``` --- @@ -90,7 +90,7 @@ Why? Javascript arrays can work as objects, dictionaries, when you are using as key any value that can not be handled by Array objects. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -106,13 +106,13 @@ console.log(arr.length); What is the result of execute "Snippet 4" code? ```js -var result = ; + ``` ```js -var result = 0; +0 ``` ```js -assert(result === 0); +__match_answer_and_solution__ ``` --- @@ -126,7 +126,7 @@ Why? Javascript arrays can work as objects, dictionaries, when you are using as key any value that can not be handled by Array objects. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -142,13 +142,13 @@ console.log(arr[Number.MIN_VALUE]); What is the result of execute "Snippet 5" code? ```js -var result = ; + ``` ```js -var result = "mary"; +"mary" ``` ```js -assert(result === "mary"); +__match_answer_and_solution__ ``` --- @@ -162,6 +162,6 @@ Why? Javascript arrays can work as objects, dictionaries, when you are using as key any value that can not be handled by Array objects. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- \ No newline at end of file diff --git a/hoisting1/README.md b/hoisting1/README.md index 108daff..5bdc161 100644 --- a/hoisting1/README.md +++ b/hoisting1/README.md @@ -25,11 +25,11 @@ Why this is happening? ``` ```js -'This is happening because the hoisting problem. Remember that in Javascript there are no block variables.' +This is happening because the hoisting problem. Remember that in Javascript there are no block variables. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -63,7 +63,18 @@ var bird = 'Pidgeons'; ``` ```js -assert(true); +assert(inputs[0] === 'Bert loves his Pidgeons'); ``` +```js +var inputs = []; +var backConsole = console; +var console = { + log: function (str) { + inputs.push(str); + backConsole.log(str); + console = backConsole; + } +}; +``` --- diff --git a/input_search/README.md b/input_search/README.md index 6881825..89e7f53 100644 --- a/input_search/README.md +++ b/input_search/README.md @@ -51,23 +51,40 @@ $( document ).ready( function() { } ); ``` ```js +function delayTimer(delay){ + var timer; + return function(fn){ + timer = clearTimeout(timer); + if(fn) + timer = setTimeout(function() { + fn(); + },delay); + + return timer; + }; +} +var delayer = delayTimer(500); + $( document ).ready( function() { $( '#inputSearch' ).keyup( function() { - $.ajax( { - url: 'http://www.domain.com/search', - data: this.value, - success: function ( data ) - { - var results = data.results; - $( '#list' ).empty(); - $.each( data, function ( item ) { - $( '#list' ).append( '
  • ' + item + '
  • ' ); - } ); + delayer(function() { + var $list = $( '#list' ); + $.ajax( { + url: 'http://www.domain.com/search', + data: this.value, + success: function ( data ) + { + var results = data.results; + $list.empty(); + $.each( data, function ( item ) { + $list.append( '
  • ' + item + '
  • ' ); + } ); - }, - error: function ( xhr, status, error ) { - console.log( 'Something goes wrong!', status, error.message ); - } + }, + error: function ( xhr, status, error ) { + console.log( 'Something goes wrong!', status, error.message ); + } + } ); } ); } ); } ); @@ -79,6 +96,9 @@ assert(counter === 1); ```js var document = ''; var counter = 0; +var setTimeout = function (cb) { + cb(); +}; var $ = function ( element ) { var jQuery = { ready: function ( callback ) { diff --git a/intro/README.md b/intro/README.md index 15c19e7..4287ca8 100644 --- a/intro/README.md +++ b/intro/README.md @@ -1 +1 @@ -#Exercises \ No newline at end of file +# \ No newline at end of file diff --git a/invaluable/README.md b/invaluable/README.md index aa1f77b..e4b2552 100644 --- a/invaluable/README.md +++ b/invaluable/README.md @@ -29,7 +29,7 @@ Because the precedence of operators, the execution workflow is: ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -54,6 +54,6 @@ Because the precedence of operators and how native methods behaviours, the execu ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- \ No newline at end of file diff --git a/nested_scopes/README.md b/nested_scopes/README.md index 3dd878e..423af01 100644 --- a/nested_scopes/README.md +++ b/nested_scopes/README.md @@ -18,7 +18,7 @@ ReferenceError: c is not defined ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -33,6 +33,6 @@ The cause of the error is because Javascript only has not block scopes as in oth ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- \ No newline at end of file diff --git a/now_you_see_me/README.md b/now_you_see_me/README.md index e1ad0a4..33c1a21 100644 --- a/now_you_see_me/README.md +++ b/now_you_see_me/README.md @@ -20,7 +20,7 @@ ReferenceError: g is not defined ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -36,6 +36,6 @@ When a function expression has a named function it can only be accessed using th ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- \ No newline at end of file diff --git a/objects2/README.md b/objects2/README.md index ab9e836..b8cc042 100644 --- a/objects2/README.md +++ b/objects2/README.md @@ -49,21 +49,18 @@ Explain why this is happening: ``` ```js -'This is happening because when the closure has been executed it has saved the reference in memory for oPerson as oTeacher and even when oPerson has changed the assigned value to a different object it continues being referenced inside the closure. It is important to check this problems because if you make the same with DOM elements and the element is removed from the DOM tree you will get memory leaks issues' +This is happening because when the closure has been executed it has saved the reference in memory for oPerson as oTeacher and even when oPerson has changed the assigned value to a different object it continues being referenced inside the closure. It is important to check this problems because if you make the same with DOM elements and the element is removed from the DOM tree you will get memory leaks issues ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- --- -Fix the code to make the third execution return -``` -Object { name: "mary", surname: "sullivan" } -``` +Fix the code to make the third execution return ``Object { name: "mary", surname: "sullivan" }`` ```js var oPerson = { name: 'john'}; diff --git a/running_man/README.md b/running_man/README.md index ded9920..974e9be 100644 --- a/running_man/README.md +++ b/running_man/README.md @@ -61,6 +61,6 @@ Why? 9007199254740992 is the maximum number that Javascript can handle then it is unable to manage due to the overflow issue, then the most easy way to do it is decrement the number in one to allow Javascript to work with it. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- \ No newline at end of file diff --git a/scope/README.md b/scope/README.md index c277f0e..b54bcf9 100644 --- a/scope/README.md +++ b/scope/README.md @@ -10,10 +10,10 @@ What it's logged when Snippet 1 is executed? ``` ```js -'function test() { test = 123; console.log( test );}()' +function test() { test = 123; console.log( test );}() ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- @@ -27,6 +27,6 @@ Why? When the code tries to modify test value inside the function it doesn't works because the precedence of the declaration of the function that test reference remains unchanged, then the code that is executed is console.log logs the function body in the console. ``` ```js -assert(true); +__match_answer_and_solution__ ``` --- \ No newline at end of file diff --git a/terminator/README.md b/terminator/README.md index c64bcd2..2fb4fc1 100644 --- a/terminator/README.md +++ b/terminator/README.md @@ -67,7 +67,6 @@ function sayonara( name ) { sayonara( '<\/script>