├── 7-kyu ├── The Office VI - Sabbatical.js └── Vowel Count.js ├── 8-kyu └── Find the first non-consecutive number.js └── README.md /7-kyu/The Office VI - Sabbatical.js: -------------------------------------------------------------------------------- 1 | /* 2 | https://www.codewars.com/kata/57fe50d000d05166720000b1/train/javascript 3 | 4 | val=your value to the organisation 5 | happ=her happiness level at the time of asking and finally 6 | The numbers of letters from 'sabbatical' that are present in string 'x'. 7 | 8 | If the sum of the three parameters (as described above) is > 22, return 'Sabbatical! Boom!', else return 'Back to your desk, boy.'. 9 | 10 | */ 11 | 12 | function sabb(x, val, happ){ 13 | let sum = (x.match(/[sabticl]/ig )|| []).length; 14 | 15 | if(sum + val + happ > 22) { 16 | return 'Sabbatical! Boom!' 17 | } else { 18 | return 'Back to your desk, boy.' 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /7-kyu/Vowel Count.js: -------------------------------------------------------------------------------- 1 | /* 2 | https://www.codewars.com/kata/54ff3102c1bad923760001f3 3 | 4 | Return the number (count) of vowels in the given string. 5 | 6 | We will consider a, e, i, o, and u as vowels for this Kata. 7 | 8 | The input string will only consist of lower case letters and/or spaces. 9 | 10 | */ 11 | 12 | function getCount(str) { 13 | var vowelsCount = 0; 14 | 15 | // enter your majic here 16 | let arr = str.split(''); 17 | for (let i = 0; i < arr.length; i++){ 18 | if (arr[i] === 'a' || arr[i] === 'e' || arr[i] === 'i' || arr[i] === 'o' || arr[i] === 'u') { 19 | vowelsCount+=1; 20 | } 21 | } 22 | 23 | return vowelsCount; 24 | } 25 | 26 | 27 | function getCount(str) { 28 | return (str.match(/[aeiou]/ig) || []).length 29 | } -------------------------------------------------------------------------------- /8-kyu/Find the first non-consecutive number.js: -------------------------------------------------------------------------------- 1 | /* 2 | https://www.codewars.com/kata/58f8a3a27a5c28d92e000144 3 | 4 | Your task is to find the first element of an array that is not consecutive. 5 | 6 | By not consecutive we mean not exactly 1 larger than the previous element of the array. 7 | 8 | E.g. If we have an array [1,2,3,4,6,7,8] then 1 then 2 then 3 then 4 are all consecutive but 6 is not, so that's the first non-consecutive number. 9 | 10 | If the whole array is consecutive then return null2. 11 | 12 | The array will always have at least 2 elements1 and all elements will be numbers. The numbers will also all be unique and in ascending order. The numbers could be positive or negative and the first non-consecutive could be either too! 13 | */ 14 | 15 | function firstNonConsecutive (arr) { 16 | 17 | for (let i = 0; i < arr.length - 1; i++) { 18 | if (Math.abs(arr[i + 1] - arr[i]) !== 1) { 19 | return tmp2; 20 | } 21 | } 22 | return null 23 | 24 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Solutions for CodeWars. 2 | 3 | My profile: [https://www.codewars.com/users/younglaker](https://www.codewars.com/users/younglaker) --------------------------------------------------------------------------------