Skip to content

Commit

Permalink
added daily codewar
Browse files Browse the repository at this point in the history
  • Loading branch information
CoriRen committed Sep 8, 2024
1 parent 4bfc14a commit f128abd
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions codewars.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,31 @@ function positiveSum2(arr) {
function disemvowel(str) {
return str.replace(/[aeiou]/gi,'')
}

//Who Likes it
function likes(names) {
if (names.length === 0){
return "No one likes this";
}else if (names.length === 1){
return `${names[0]} likes this`;
}else if (names.length === 2){
return `${names[0]} and ${names[1]} like this`;
}else if (names.length === 3){
return `${names[0]}, ${names[1]}, and ${names[2]} like this`
}else{
return `${names[0]}, ${names[1]}, and ${names.length-2} others like this`
}
}

//String ends with?
function solution(str, ending){
let num = str.length - ending.length
let newStr = str.split('').slice(num).join('')
return ending === newStr ? true : false
}

//OR
function solution(str, ending){
return str.endsWith(ending)
}

0 comments on commit f128abd

Please sign in to comment.