Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
36
Task/Pangram-checker/JavaScript/pangram-checker-2.js
Normal file
36
Task/Pangram-checker/JavaScript/pangram-checker-2.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
var _ = require("underscore");
|
||||
|
||||
// Curried mixin function
|
||||
// Utility Methods
|
||||
_.mixin({
|
||||
checkAToZ: function(s) {
|
||||
return function(letter) {
|
||||
if (s.indexOf(letter) != -1) { return true};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
_.mixin({
|
||||
toLower: function(str) {
|
||||
return str.toLowerCase();
|
||||
}
|
||||
});
|
||||
|
||||
_.mixin({
|
||||
isPangram: function(lstr) {
|
||||
var letters = "zqxjkvbpygfwmucldrhsnioate".split('');
|
||||
return _.every(letters, _.checkAToZ(lstr));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var panGramStr = "The quick brown fox jumps over the lazy dog";
|
||||
var IsPanGram = function(panGramStr) {
|
||||
return _.chain(panGramStr).toLower().isPangram().value();
|
||||
};
|
||||
|
||||
console.log("Result IsPanGram - \"", panGramStr,"\" - " , IsPanGram.call(this,panGramStr));
|
||||
console.log("Result IsPanGram - \"", "the World","\" - ", IsPanGram.call(this, "the World"));
|
||||
|
||||
// Result IsPanGram - " The quick brown fox jumps over the lazy dog " - true
|
||||
// Result IsPanGram - " the World " - false
|
||||
Loading…
Add table
Add a link
Reference in a new issue