Created
April 17, 2015 06:33
-
-
Save ppbntl19/af2f20d4f4b785c3299d to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/bihanekiva
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var old = ('Iseeit Inc'); | |
var str2 = ('iseeiT'); | |
var str3 =('isEEit Inc'); | |
var str4 =('isEEitNEW Inc'); | |
var str5 =('isEEit Aus'); | |
console.log(determineConflict(old,str2)); | |
console.log(determineConflict(old,str3)); | |
console.log(determineConflict(old,str4)); | |
console.log(determineConflict(old,str5)); | |
function determineConflict(o,n){ | |
if(checkExactMatch(o,n)){ | |
return {conflict: true, partialMatch: false}; | |
} | |
if(checkPartialMatch(o,n)){ | |
return {conflict: true, partialMatch: true}; | |
} | |
return {conflict: false}; | |
} | |
function checkPartialMatch(o,n){ | |
var result = false ; | |
o = o.split(' '); | |
n = n.split(' '); | |
if(o[0].toLowerCase() == n[0].toLowerCase()){ | |
result = true; | |
} | |
return result; | |
} | |
function checkExactMatch(o,n){ | |
var result = false; | |
if(o.toLowerCase() == n.toLowerCase()){ | |
result = true; | |
} | |
return result; | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var old = ('Iseeit Inc'); | |
var str2 = ('iseeiT'); | |
var str3 =('isEEit Inc'); | |
var str4 =('isEEitNEW Inc'); | |
var str5 =('isEEit Aus'); | |
console.log(determineConflict(old,str2)); | |
console.log(determineConflict(old,str3)); | |
console.log(determineConflict(old,str4)); | |
console.log(determineConflict(old,str5)); | |
function determineConflict(o,n){ | |
if(checkExactMatch(o,n)){ | |
return {conflict: true, partialMatch: false}; | |
} | |
if(checkPartialMatch(o,n)){ | |
return {conflict: true, partialMatch: true}; | |
} | |
return {conflict: false}; | |
} | |
function checkPartialMatch(o,n){ | |
var result = false ; | |
o = o.split(' '); | |
n = n.split(' '); | |
if(o[0].toLowerCase() == n[0].toLowerCase()){ | |
result = true; | |
} | |
return result; | |
} | |
function checkExactMatch(o,n){ | |
var result = false; | |
if(o.toLowerCase() == n.toLowerCase()){ | |
result = true; | |
} | |
return result; | |
} | |
</script></body> | |
</html> |
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
var old = ('Iseeit Inc'); | |
var str2 = ('iseeiT'); | |
var str3 =('isEEit Inc'); | |
var str4 =('isEEitNEW Inc'); | |
var str5 =('isEEit Aus'); | |
console.log(determineConflict(old,str2)); | |
console.log(determineConflict(old,str3)); | |
console.log(determineConflict(old,str4)); | |
console.log(determineConflict(old,str5)); | |
function determineConflict(o,n){ | |
if(checkExactMatch(o,n)){ | |
return {conflict: true, partialMatch: false}; | |
} | |
if(checkPartialMatch(o,n)){ | |
return {conflict: true, partialMatch: true}; | |
} | |
return {conflict: false}; | |
} | |
function checkPartialMatch(o,n){ | |
var result = false ; | |
o = o.split(' '); | |
n = n.split(' '); | |
if(o[0].toLowerCase() == n[0].toLowerCase()){ | |
result = true; | |
} | |
return result; | |
} | |
function checkExactMatch(o,n){ | |
var result = false; | |
if(o.toLowerCase() == n.toLowerCase()){ | |
result = true; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment