Created
December 13, 2019 00:02
-
-
Save angelyoung24/4ac26322fab6407ccafc751c3a2d355c to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/miyaroz
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"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
// Who Likes It from Codewars: https://www.codewars.com/kata/who-likes-it/train/javascript | |
function likes(names) { | |
names = names || []; | |
switch(names.length) { | |
case 0: return "no one likes this"; | |
break; | |
case 1: return names[0] + " likes this"; | |
break; | |
case 2: return names[0] + " and " + names[1] + " like this"; | |
break; | |
case 3: return names[0] + ", " + names[1] + " and " + names[2] + " like this"; | |
break; | |
default: return names[0] + ", " + names[1] + " and " + (names.length - 2) + " others like this"; | |
} | |
} | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">// Who Likes It from Codewars: https://www.codewars.com/kata/who-likes-it/train/javascript | |
function likes(names) { | |
names = names || []; | |
switch(names.length) { | |
case 0: return "no one likes this"; | |
break; | |
case 1: return names[0] + " likes this"; | |
break; | |
case 2: return names[0] + " and " + names[1] + " like this"; | |
break; | |
case 3: return names[0] + ", " + names[1] + " and " + names[2] + " like this"; | |
break; | |
default: return names[0] + ", " + names[1] + " and " + (names.length - 2) + " others like this"; | |
} | |
} | |
</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
// Who Likes It from Codewars: https://www.codewars.com/kata/who-likes-it/train/javascript | |
function likes(names) { | |
names = names || []; | |
switch(names.length) { | |
case 0: return "no one likes this"; | |
break; | |
case 1: return names[0] + " likes this"; | |
break; | |
case 2: return names[0] + " and " + names[1] + " like this"; | |
break; | |
case 3: return names[0] + ", " + names[1] + " and " + names[2] + " like this"; | |
break; | |
default: return names[0] + ", " + names[1] + " and " + (names.length - 2) + " others like this"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment