From 68197258910ffd6e8dd3aae417436cd4c004c0c9 Mon Sep 17 00:00:00 2001 From: Guilherme Uhelski Date: Sat, 21 Dec 2013 11:53:15 -0200 Subject: [PATCH 01/11] Fix indentation. --- topics/about_control_structures.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topics/about_control_structures.js b/topics/about_control_structures.js index ca2631c2..767d266c 100644 --- a/topics/about_control_structures.js +++ b/topics/about_control_structures.js @@ -25,7 +25,7 @@ test("for in", function() { var result = ""; // for in enumerates the property names of an object for (var property_name in person) { - result = result + property_name; + result = result + property_name; }; equal(__, result, 'what is the value of result?'); }); From bb3e0e3041e834340ad80bb09a1fa14e8c059378 Mon Sep 17 00:00:00 2001 From: Alexander Jeng Date: Sun, 21 Sep 2014 21:07:29 -0700 Subject: [PATCH 02/11] Fixed indentation --- jskoans.htm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jskoans.htm b/jskoans.htm index 5113fe4e..a6bc4c00 100644 --- a/jskoans.htm +++ b/jskoans.htm @@ -30,7 +30,7 @@ -

JavaScript Koans

+

JavaScript Koans

To begin, find the file 'topics/about_asserts.js', and complete the tests.

From 7924d3be79a83029267fe2a475401d85f6553d27 Mon Sep 17 00:00:00 2001 From: ar1g Date: Mon, 6 Oct 2014 00:42:09 +0100 Subject: [PATCH 03/11] typo referer corrected to refer --- topics/about_this.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topics/about_this.js b/topics/about_this.js index 91b3135c..85185f04 100644 --- a/topics/about_this.js +++ b/topics/about_this.js @@ -23,7 +23,7 @@ test("'this' on unattached function", function () { // if the function is not called as an object property 'this' is the global context // (window in a browser). This is an example. Please do not do this in practise. window.__ = 'Peter'; - equal(alias(), "Hello, my name is Peter", "What does 'this' referer to when it is not part of an object?"); + equal(alias(), "Hello, my name is Peter", "What does 'this' refer to when it is not part of an object?"); }); test("'this' set explicitly", function () { @@ -36,7 +36,7 @@ test("'this' set explicitly", function () { // calling a function with 'call' lets us assign 'this' explicitly var message = person.intro.call({__: "Frank"}); - equal(message, "Hello, my name is Frank", "What does 'this' referer to when you use the 'call()' method?"); + equal(message, "Hello, my name is Frank", "What does 'this' refer to when you use the 'call()' method?"); }); // extra credit: underscore.js has a 'bind' function http://documentcloud.github.com/underscore/#bind From 42d6ac06052b5c7e403538ebde815014c1557c9f Mon Sep 17 00:00:00 2001 From: Lewis Cowper Date: Sat, 7 Feb 2015 16:45:15 +0000 Subject: [PATCH 04/11] Unnecessary semicolon --- topics/about_control_structures.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topics/about_control_structures.js b/topics/about_control_structures.js index 767d266c..aca1623b 100644 --- a/topics/about_control_structures.js +++ b/topics/about_control_structures.js @@ -26,7 +26,7 @@ test("for in", function() { // for in enumerates the property names of an object for (var property_name in person) { result = result + property_name; - }; + } equal(__, result, 'what is the value of result?'); }); From 4e065dcd9186ed44517773d27b53fd10aee8507a Mon Sep 17 00:00:00 2001 From: Yihang Ho Date: Fri, 13 Mar 2015 22:37:17 +0800 Subject: [PATCH 05/11] Automatically scroll to the bottom. --- support/koans.js | 1 + 1 file changed, 1 insertion(+) diff --git a/support/koans.js b/support/koans.js index b367170c..4f11ea54 100644 --- a/support/koans.js +++ b/support/koans.js @@ -56,6 +56,7 @@ Array.prototype.equalTo = function(compareTo) { if (failures > 0) { $("#zen-help").show(); } + $("body").scrollTop($(document).height()); }); QUnit.log(function(result) { From 13e8d62f4002e3fa157b9b3ccc957369b38860cc Mon Sep 17 00:00:00 2001 From: Jake Worth Date: Thu, 3 Dec 2015 08:52:58 -0500 Subject: [PATCH 06/11] Fix double word typo --- topics/about_functions_and_closure.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topics/about_functions_and_closure.js b/topics/about_functions_and_closure.js index 7eb20777..d435c232 100644 --- a/topics/about_functions_and_closure.js +++ b/topics/about_functions_and_closure.js @@ -67,7 +67,7 @@ test("using apply to invoke function",function(){ //similar to the call function is the apply function. Apply only has two //arguments: the first is the context that this should be set to in the called - //function and and array of arguments to be passed into the called function. + //function and the second is the array of arguments to be passed into the called function. var result = invokee.apply("I am this!", ["I am arg1","I am arg2"]); equal(__, result, "what will the value of invokee's this be?"); From 5a681fef8049bdf3f349e6d8dcddeace064328db Mon Sep 17 00:00:00 2001 From: Bartosz Cytrowski Date: Wed, 28 Sep 2016 01:33:28 +0200 Subject: [PATCH 07/11] Make reflection topic browser-independent Chrome and Firefox handle `.name` function attribute differently if it comes to anonymous functions. For more details see: https://github.com/liammclennan/JavaScript-Koans/issues/53 --- topics/about_reflection.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/topics/about_reflection.js b/topics/about_reflection.js index 51e7c8ff..63868648 100644 --- a/topics/about_reflection.js +++ b/topics/about_reflection.js @@ -1,10 +1,10 @@ module("About Reflection (topics/about_reflection.js)"); -var A = function() { - this.aprop = "A"; +function A() { + this.aprop = "A"; }; -var B = function() { +function B() { this.bprop = "B"; }; @@ -14,7 +14,7 @@ test("typeof", function() { equal(__, typeof({}), 'what is the type of an empty object?'); equal(__, typeof('apple'), 'what is the type of a string?'); equal(__, typeof(-5), 'what is the type of -5?'); - equal(__, typeof(false), 'what is the type of false?'); + equal(__, typeof(false), 'what is the type of false?'); }); test("property enumeration", function() { @@ -40,7 +40,7 @@ test("hasOwnProperty", function() { equal(__, keys.length, 'how many elements are in the keys array?'); deepEqual([__, __], keys, 'what are the properties of the array?'); - // hasOwnProperty returns true if the parameter is a property directly on the object, + // hasOwnProperty returns true if the parameter is a property directly on the object, // but not if it is a property accessible via the prototype chain. var ownKeys = []; for(propertyName in b) { @@ -56,8 +56,8 @@ test("constructor property", function () { var a = new A(); var b = new B(); equal(__, typeof(a.constructor), "what is the type of a's constructor?"); - equal(__, a.constructor.name, "what is the name of a's constructor?"); - equal(__, b.constructor.name, "what is the name of b's constructor?"); + equal(__, a.constructor.name, "what is the name of a's constructor?"); + equal(__, b.constructor.name, "what is the name of b's constructor?"); }); test("eval", function() { From 9737311144b43169eebcfd4cf22823fc2613dc1a Mon Sep 17 00:00:00 2001 From: Bartosz Cytrowski Date: Wed, 28 Sep 2016 02:03:59 +0200 Subject: [PATCH 08/11] Display more details in splice example Naming of variables was confusing + there was no hint in the qunit output. For more details see: https://github.com/liammclennan/JavaScript-Koans/issues/47 --- jskoans.htm | 7 +++---- topics/about_arrays.js | 6 ++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/jskoans.htm b/jskoans.htm index a6bc4c00..f9427527 100644 --- a/jskoans.htm +++ b/jskoans.htm @@ -1,5 +1,5 @@ - + @@ -26,8 +26,7 @@ - - +

JavaScript Koans

diff --git a/topics/about_arrays.js b/topics/about_arrays.js index 3d4cd41f..10a7eae5 100644 --- a/topics/about_arrays.js +++ b/topics/about_arrays.js @@ -19,8 +19,10 @@ test("length", function() { test("splice", function() { var daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']; var workingWeek = daysOfWeek.splice(__, __); - ok(workingWeek.equalTo([__]), 'what is the value of workingWeek?'); - ok(daysOfWeek.equalTo([__]), 'what is the value of daysOfWeek?'); + var weekend = daysOfWeek; + + deepEqual(workingWeek, ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'], 'what is the value of workingWeek?'); + deepEqual(weekend, ['Saturday', 'Sunday'], 'what is the value of daysOfWeek?'); }); test("stack methods", function() { From 63a31e91a3117d8f26ba6af1b399d4473b18eba4 Mon Sep 17 00:00:00 2001 From: Bartosz Cytrowski Date: Wed, 28 Sep 2016 09:37:14 +0200 Subject: [PATCH 09/11] Fix wording in assertion description --- topics/about_arrays.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topics/about_arrays.js b/topics/about_arrays.js index 10a7eae5..b2de2547 100644 --- a/topics/about_arrays.js +++ b/topics/about_arrays.js @@ -22,7 +22,7 @@ test("splice", function() { var weekend = daysOfWeek; deepEqual(workingWeek, ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'], 'what is the value of workingWeek?'); - deepEqual(weekend, ['Saturday', 'Sunday'], 'what is the value of daysOfWeek?'); + deepEqual(weekend, ['Saturday', 'Sunday'], 'what is the value of weekend?'); }); test("stack methods", function() { From 3e3c84cac06dcec1d6119826d8d06ab739b4ef6a Mon Sep 17 00:00:00 2001 From: Liam McLennan Date: Tue, 6 Dec 2016 13:20:36 +1000 Subject: [PATCH 10/11] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index f71fcfcc..6a5de4ac 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ Update ====== -> If you like JavaScript Koans you might enjoy my newer, more user friendly, project [Didacto: JavaScript](http://javascript.didacto.net/) - JavaScript Koans is an interactive learning environment that uses failing tests to introduce students to aspects of JavaScript in a logical sequence. The inspiration for this project comes from the Edgecase Ruby Koans and the book 'Javascript: The Good Parts'. From 85396112fd6449c65eb756051806b578a7f27ead Mon Sep 17 00:00:00 2001 From: David Fourney Date: Tue, 6 Jun 2017 21:31:01 -0400 Subject: [PATCH 11/11] Fix three typos --- topics/about_functions_and_closure.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/topics/about_functions_and_closure.js b/topics/about_functions_and_closure.js index d435c232..7477278f 100644 --- a/topics/about_functions_and_closure.js +++ b/topics/about_functions_and_closure.js @@ -3,7 +3,7 @@ module("About Functions And Closure (topics/about_functions_and_closure.js)"); test("defining functions directly", function() { var result = "a"; function changeResult() { - // the ability to access a variables defined in the same scope as the function is known as 'closure' + // the ability to access variables defined in the same scope as the function is known as 'closure' result = "b"; }; changeResult(); @@ -52,9 +52,9 @@ test("using call to invoke function",function(){ }; //another way to invoke a function is to use the call function which allows - //you to set the callers "this" context. Call can take any number of arguments: + //you to set the caller's "this" context. Call can take any number of arguments: //the first one is always the context that this should be set to in the called - //function, and the arguments to be sent to the function,multiple arguments are separated by commas. + //function, and the arguments to be sent to the function, multiple arguments are separated by commas. var result = invokee.call("I am this!", "Where did it come from?"); equal(__, result, "what will the value of invokee's this be?");