This repository has been archived by the owner on Feb 16, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
67 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
node nicknames.js | uniq -D -w 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var people = require('../people'); | ||
var _ = require('lodash'); | ||
|
||
var PHONE_PATTERN = /^\d{3}-\d{3}-\d{4}$/; | ||
|
||
function isValidPhoneNumber(phoneNumber){ | ||
return PHONE_PATTERN.test(phoneNumber); | ||
} | ||
|
||
console.log("Malformed phone numbers:"); | ||
|
||
_(people) | ||
.forEach(function(person){ | ||
var mobilePhone = person.mobilePhone; | ||
var workPhone = person.workPhone; | ||
|
||
if(mobilePhone && !isValidPhoneNumber(mobilePhone)){ | ||
console.warn("%s: %s", person.fullname, person.mobilePhone); | ||
} | ||
|
||
if(workPhone && !isValidPhoneNumber(workPhone)){ | ||
console.warn("%s: %s", person.fullname, person.workPhone); | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var people = require('../people'); | ||
var _ = require('lodash'); | ||
|
||
_(people) | ||
.sortBy('fullname') | ||
.map(function(person){ | ||
person.nickname = person.fullname.split(/\s/).map(function(name){ | ||
var firstInitial = name.charAt(0).toLowerCase(); | ||
return (firstInitial == '(') | ||
? '' | ||
: firstInitial; | ||
}).join(''); | ||
return person; | ||
}) | ||
.forEach(function(person){ | ||
console.log(person.nickname + '\t' + person.fullname); | ||
}); |