Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Task3/question1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// http://www.codewars.com/kata/prefill-an-array

function prefill(n, v) {

if (isNaN(n) || Number(n) == NaN || n === Infinity || n === -Infinity || n < 0 || typeof(n) == 'boolean' || n % 1 != 0)
throw new TypeError(n + " is invalid");
else {
arr = (new Array(Number(n))).fill(v);
}
return arr;
}
7 changes: 7 additions & 0 deletions Task3/question2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// http://www.codewars.com/kata/a-function-within-a-function

function always(n) {
return function() {
return n
}
}
13 changes: 13 additions & 0 deletions Task3/question3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// http://www.codewars.com/kata/closures-and-scopes/train/javascript

function createFunctions(n) {
var callbacks = [];

for (let i = 0; i < n; i++) {
callbacks.push(function() {
return i;
});
}

return callbacks;
}
13 changes: 13 additions & 0 deletions Task3/question4.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// http://www.codewars.com/kata/can-you-keep-a-secret

function createSecretHolder(secret) {
return {
sec: secret,
getSecret: function() {
return this.sec;
},
setSecret: function(b) {
this.sec = b;
}
}
}