--- tags: Codetisan - JavaScript title: JavaScript Challenge description: Coding Problems --- ## Sort letters in alphabetical order Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/ckw1oigoc01800vl642aww161/javascript/sort-letters-in-alphabetical-order) Sort the letters of a given string in alpabetical order. Sample Code: ```javascript function sortLetter(str) { // Enter your logic here... } ``` Examples: ```code Input: 'codetisan' Output: 'acdeinost' Explanation: The letters of the output are sorted in alphabetical order. ``` ```code Input: 'letter' Output: 'eelrtt' Explanation: The letters of the output are sorted in alphabetical order. ``` Submission: ```javascript const sortLetter = (str) => str.split('').sort((a, b) => a.localeCompare(b)).join(''); ``` ## Convert positive integers to negative integers Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1ngbg1e17540wmm9skkrdkk/javascript/constant-negative) Given a number, return the number with a negative sign. Sample Code: ```javascript function negNum(num) { // Enter your logic here... } ``` Examples: ```code Input: 5 Output: -5 Explanation: The input number has been converted to a negative number. ``` ```code Input: -1 Output: -1 Explanation: The input is already a negative number. ``` Submission: ```javascript const negNum = (num) => num > 0 ? -num : num; ``` ## Remove first and last letters Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1ngvc5o01030ul79jrq0pb4/javascript/removing-letters) Given a string, return the string without its first and last characters. Sample Code: ```javascript function lettersRmv(str) { // Enter your logic here... } ``` Examples: ```code Input: 'Codetisan' Output: 'odetisa' Explanation: The first and last letters have been removed. ``` ```code Input: '01' Output: '' Explanation: The first and last letters have been removed. ``` Submission: ```javascript const lettersRmv = (str) => str.slice(1, -1); ``` ## Starting elements in String Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1p6eyjv01890vl4y8afsahw/javascript/starting-elements) Return true if the given string starts with 'Code'. Sample Code: ```javascript function startsWith(str) { // Enter your logic here... } ``` Examples: ```code Input: 'Codetisan' Output: true Explanation: 'Codetisan' starts with 'Code'. ``` ```code Input: 'meow' Output: false Explanation: 'meow' does not start with 'Code'. ``` Submission: ```javascript const startsWith = (str) => str.startsWith('Code'); ``` ## Extract the first element of an Array Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1osz47n00980vmjc3ytk0wj/javascript/the-first-element) Given an array, return the very first element. Sample Code: ```javascript function firstEle(arr) { // Enter your logic here... } ``` Examples: ```code Input: [1,2,3,4] Output: 1 Explanation: Element 1 has an index value of zero. ``` ```code Input: [[1,2],[3,4]] Output: [1,2] Explanation: Element [1,2] has an index value of zero. ``` Submission: ```javascript const firstEle = (arr) => arr[0]; ``` ## Get the largest even number from an array Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/ckw26pfan03950wjxufbb7517/javascript/get-the-largest-even-number-from-an-array) Given an integer array, get the largest even number from the array, return -1 if not found. Sample Code: ```javascript function getTheLargest(arr) { // Enter your logic here... } ``` Examples: ```code Input: [2,3,4,10,5,8] Output: 10 Explanation: The largest even number in the array is 10. ``` ```code Input: [3,1,9,17] Output: -1 Explanation: Cannot find the largest even number, return -1 instead. ``` Submission: ```javascript const getTheLargest = (arr) => { arr.sort((a, b) => b - a); for (let i of arr) { if (i % 2 === 0) { return i; } } return -1; }; ``` ## Keywords detector Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1n9ew5b05920vlc58cavhk1/javascript/keywords-detector) Return true if the input contains "girlfriend". Otherwise false. Sample Code: ```javascript function spotCheck(str) { // Enter your logic here... } ``` Examples: ```code Input: 'I have a girlfriend on my monitor.' Output: true Explanation: "girlfriend" to be found in the input. ``` ```code Input: 'This world shall know code.' Output: false Explanation: "girlfriend" 404 not found! ``` Submission: ```javascript const spotCheck = (str) => str.includes('girlfriend'); ``` ## Retirement age Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1qlixgt00920wjy5lck3sj5/javascript/retirement-age) Given your today’s years old, how many more years until retirement? Assuming 60 years old is the age for retiring. Sample Code: ```javascript function retireYears(num) { // Enter your logic here... } ``` Examples: ```code Input: 60 Output: 'You are ready to retire.' Explanation: 60 - 60 = 0 ``` ```code Input: 1 Output: 'You have 59 more years to go.' Explanation: 60 - 1 = 59 ``` Submission: ```javascript const retireYears = (num) => num < 60 ? `You have ${60 - num} more years to go.` : 'You are ready to retire.'; ``` ## Simple addition Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1otf94302430vmjqe20apo6/javascript/number-plus-one) Given a number, increase the number by 1 and return a new value. Sample Code: ```javascript function plusOne(num) { // Enter your logic here... } ``` Examples: ```code Input: 1 Output: 2 Explanation: 1 + 1 = 2 ``` ```code Input: -999 Output: -998 Explanation: -999 + 1 = -998 ``` Submission: ```javascript const plusOne = (num) => num + 1; ``` ## Masking credit card number Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1nbqkns02950vm80st16yze/javascript/convert-letters-into-asterisk-symbol) Given a number and an integer (n), return a new string as shown in the examples. Sample Code: ```javascript function coverUp(num,n) { // Enter your logic here... } ``` Examples: ```code Input: 123456,3 Output: '***456' Explanation: The first 3 numbers have been replaced by asterisk symbols. ``` ```code Input: 12345678,4 Output: '****5678' Explanation: The first 4 numbers have been replaced by asterisk symbols. ``` Submission: ```javascript const coverUp = (num, n) => { for (let i = 0; i < n; i ++) { num = num.toString().replace(/[0-9]/, '*'); } return num; } ``` ## Inspect ASCII value Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1p79ex405510wl559jrf341/javascript/ascii-value) Return the ASCII value of the given input. Sample Code: ```javascript function asciiVal(inp) { // Enter your logic here... } ``` Examples: ```code Input: 'a' Output: 97 Explanation: The character code for 'a' is 97. ``` ```code Input: 0 Output: 48 Explanation: The character code for 0 is 48. ``` Submission: ```javascript const asciiVal = (inp) => inp.charCodeAt(); ``` ## Every numbers must be less than 100 Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1p08w5o00050wml0fua5auw/javascript/every-numbers-are-less-than-100) GIven an array, return true if every element are < 100. Otherwise false. Sample Code: ```javascript function hundredLess(arr) { // Enter your logic here... } ``` Examples: ```code Input: [-1,0,1,2,99.9] Output: true Explanation: Every number in the array are less than 100. ``` ```code Input: [-1,0,1,2,999.9] Output: false Explanation: At least one of the elements is not less than 100. ``` Submission: ```javascript const hundredLess = (arr) => arr.every(i => i < 100); ``` ## Determine the length of a String Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1q78e3n24430wjx1qdi2tfn/javascript/counting-stars) Return the amount of character in the given string. Sample Code: ```js function letterCount(str) { // Enter your logic here... } ``` Examples: ```code Input: 'Codetisan' Output: 9 Explanation: There are 9 characters to be found. ``` ```code Input: ' Java Javascript ' Output: 17 Explanation: 17 characters to be found. Yes, including the spaces. ``` Submission: ```javascript const letterCount = (str) => str.length; ``` ## Largest number in the Array Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1qqfaeh00160wlgy9o4udy3/javascript/largest-number-in-the-array) GIven an array of numbers, return the largest number. Sample Code: ```javascript function topNum(arr) { // Enter your logic here... } ``` Examples: ```code Input: [1,3,4,5,3,9] Output: 9 Explanation: 9 is the largest value among all the elements. ``` ```code Input: [-1,-2,0,-3,-4] Output: 0 Explanation: 0 is the largest value among all the elements. ``` Submission: ```javascript const topNum = (arr) => Math.max(...arr); ``` ## Add Two Numbers Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/ckvg8oykk00800wml87uzlaa3/javascript/add-two-numbers) Given the first input n1 and second input n2, calculate the sum of n1 + n2 and return the sum. Sample Code: ```javascript function sum(n1, n2) { // Enter your logic here... } ``` Examples: ```code Input: n1=1, n2=1 Output: 2 Explanation: The sum of 1 and 1 equals to 2 ``` ```code Input: n1=2, n2=-2 Output: 0 Explanation: The sum of 2 and -2 equals to 0 ``` Submission: ```javascript const sum = (n1, n2) => n1 + n2; ``` ## Calculate the sum of positive numbers in an Array Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1nj3zum00330wlc3vmah67i/javascript/sum-of-positive-numbers) Given an array of numbers, return the summation of all positive numbers in the array. Sample Code: ```js function sumPos(arr) { // Enter your logic here... } ``` Examples: ```code Input: [1,2,3,-999] Output: 6 Explanation: The positive numbers are 1,2,3. ``` ```code Input: [1,-2,-3,-999] Output: 1 Explanation: The only positive number is 1. ``` Submission: ```javascript const sumPos = (arr) => arr.reduce((temp, i) => i > 0 ? temp + i : temp, 0); ``` ## Extract the first four String elements Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1otx6ng01450xmidx70flhj/javascript/first-four-letters) Return the first 4 letters of the given string. Sample Code: ```js function firstFour(str) { // Enter your logic here... } ``` Examples: ```code Input: 'Codetisan' Output: 'Code' Explanation: Elements from index 0 to 3 will be returned. ``` ```code Input: '01100011' Output: '0110' Explanation: Elements from index 0 to 3 will be returned. ``` Submission: ```javascript const firstFour = (str) => str.slice(0, 4); ``` ## Joining two Arrays without duplicate elements Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1q1vuor02940wl9m5b6j3uc/javascript/joining-two-arrays-without-duplicate-elements) Given two arrays, arr1 and arr2. Return a new array containing all the elements from both arr1 and arr2 without any duplicates. Sample Code: ```javascript function joinArr(arr1,arr2) { // Enter your logic here... } ``` Examples: ```code Input: [1,2,3],[1,2,3] Output: [1,2,3] Explanation: The removed duplicates are 1,2, and 3. ``` ```code Input: ['Javascript','ReactJS','NodeJS'], ['Typescript','ReactJS','NextJS'] Output: ['Javascript','ReactJS','NodeJS','Typescript','NextJS'] Explanation: The removed duplicate is 'ReactJS'. ``` Submission: ```javascript const joinArr = (arr1, arr2) => Array.from(new Set(arr1.concat(arr2))); ``` ## Check whether digits of an integer has an increasing sequence Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/ckw26pz4z00760wlbjrr1vtsz/javascript/check-whether-digits-of-an-integer-has-an-increasing-sequence) Given an integer, check whether digits of the integer has an increasing sequence. Sample Code: ```javascript function isIncreasing(number) { // Enter your logic here... } ``` Examples: ```code Input: 1234 Output: true Explanation: 1,2,3,4 is an increasing sequence. ``` ```code Input: 2571 Output: false Explanation: 2,5,7,1 is not an increasing sequence. ``` Submission: ```javascript const isIncreasing = (number) => { const arr = number.toString().split(''); for (let i = 0; i < arr.length - 1; i ++) { if (parseInt(arr[i]) >= parseInt(arr[i + 1])) { return false; } } return true; } ``` ## Determine the length of an array Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/ckw4vbj6a015812l51p0vrmw9/javascript/determine-the-length-of-an-array) Calculate and return the length of an array. Sample Code: ```javascript function calcSize(a) { // Enter your logic here... } ``` Examples: ```code Input: [1,2,3,4,5] Output: 5 Explanation: There are 5 elements in the given array. ``` ```code Input: [] Output: 0 Explanation: Given array is empty. ``` Submission: ```javascript const calcSize = (a) => a.length; ``` ## Comparing Arrays Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1q48mam03750vl332wkratl/javascript/comparing-arrays) Perform a simple comparison between the given arrays. Return true if both the arrays carry the same elements and elements order. Otherwise false. Sample Code: ```javascript function compArr(arr1,arr2) { // Enter your logic here... } ``` Examples: ```code Input: [1,2,3, {key:value}],[1,2,3,{key:value}] Output: true Explanation: Both have the same elements and elements order. ``` ```code Input: [1,2,3],[1,2,'3'] Output: false Explanation: '3' is not equivalent to 3 due to different data types. ``` Submission: ```javascript const compArr = (arr1, arr2) => JSON.stringify(arr1) === JSON.stringify(arr2); ``` ## Finding out data type Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1qo3mj500360wjlgm1iyj7e/javascript/finding-out-data-type) Return the data type of the given input. Sample Code: ```javascript function naniTheWhat(inp) { // Enter your logic here... } ``` Examples: ```code Input: true Output: 'boolean' Explanation: Boolean type has two values. True and false. ``` ```code Input: ' ' Output: 'string' Explanation: Anything inside the quotation is considered as string. ``` Submission: ```javascript const naniTheWhat = (inp) => typeof(inp); ``` ## Some are even numbers Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1p3tp6i09590wl7be3pw4pc/javascript/some-are-even-numbers) Return true if the given array consists of even numbers. Otherwise false. Sample Code: ```javascript function someEven(arr) { // Enter your logic here... } ``` Examples: ```code Input: [1,2,3,4,5] Output: true Explanation: 2 and 4 are even numbers. ``` ```code Input: [1,'Happy',3,'Coding',5] Output: false Explanation: There are no even numbers. ``` Submission: ```javascript const someEven = (arr) => arr.some(i => i % 2 === 0); ``` ## Count the number of vowels in a given string Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/ckw1rc7f2013211mlfxnqk2nj/javascript/count-the-number-of-vowels-in-a-given-string) Count the number of vowels appeared in a given string. Sample Code: ```javascript function countVowel(str) { // Enter your logic here... } ``` Examples: ```code Input: 'Codetisan' Output: 4 Explanation: 'Codetisan' contains 4 vowels (o, e, i, a) ``` ```code Input: 'shhhh' Output: 0 Explanation: 'shhhh' has no vowel. ``` Submission: ```javascript const countVowel = (str) => str.match(/[aeiou]/gi) === null ? 0 : str.match(/[aeiou]/gi).length; ``` ## Say no to hardcoding Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1nd6s4207290wmmb7vx6a1p/javascript/say-no-to-hardcoding) Create a function that receives a number and return the output as shown in the examples. Here is your arrow: → Sample Code: ```javascript function noHardcode(num) { // Enter your logic here... } ``` Examples: ```code Input: 3 Output: 'There are 3 arrows→→→' Explanation: There are 3 arrows. ``` ```code Input: 0 Output: 'There are 0 arrow' Explanation: There are 0 arrow. ``` Submission: ```javascript const noHardcode = (num) => { let arrow = ''; for (let i = 0; i < num; i ++) { arrow += '→'; } return `There are ${num} ${num !== 0 ? `arrows${arrow}` : 'arrow'}` } ``` ## Truthy and falsy values Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1q7qtqa02150vkx9ff87duj/javascript/truthy-and-falsy-values) Based on the input, return a boolean value. Sample Code: ```javascript function trueFalse(inp) { // Enter your logic here... } ``` Examples: ```code Input: 'Javascript' Output: true Explanation: String is a truthy value. ``` ```code Input: '' Output: false Explanation: Empty string is a falsy value. ``` Submission: ```javascript const trueFalse = (inp) => inp !== ''; ``` ## Removing whitespace Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1ufos6k01870vmdaqc6jcx3/javascript/removing-whitespace) Given a string, remove leading or trailing whitespaces and return a new string. Sample Code: ```javascript function rmvSpace(str) { // Enter your logic here... } ``` Examples: ```code Input: 'Tom and Jerry ' Output: 'Tom and Jerry' Explanation: Whitespaces are removed from both sides of the string. ``` ```code Input: ' Javascript ' Output: 'Javascript' Explanation: Whitespaces are removed from both sides of the string. ``` Submission: ```javascript const rmvSpace = (str) => str.trim(); ``` ## Convert a number to hours and minutes Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/ckw1k7s6g000012joqnpfxngr/javascript/convert-a-number-to-hours-and-minutes) Write a JavaScript function to convert a given number in minutes to hours and minutes. Sample Code: ```javascript function convertTime(num) { // Enter your logic here... } ``` Examples: ```code Input: 235 Output: '3:55' Explanation: 235 is equal to 3 hours and 55 minutes. ``` ```code Input: 1060 Output: '17:40' Explanation: 1060 is equal to 17 hours and 40 minutes. ``` Submission: ```javascript const convertTime = (num) => `${~~(num / 60)}:${num % 60}` ``` ## Array creation Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1qc2ihb00850wl8074um8xj/javascript/array-creation) Given two inputs, return an array containing those two inputs. Sample Code: ```javascript function createArray(inp1,inp2) { // Enter your logic here... } ``` Examples: ```code Input: {obj: 1}, [2] Output: [{obj: 1}, [2]] Explanation: The two inputs have now been stored in an array as elements. ``` ```code Input: ' ',0 Output: [' ',0] Explanation: The two inputs have now been stored in an array as elements. ``` Submission: ```javascript const createArray = (inp1, inp2) => [...[inp1], ...[inp2]]; ``` ## Spaceless String Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1np470s19180vmnmq5e4bri/javascript/spaceless) Given a string, return the string without any spaces. Sample Code: ```javascript function noSpace(str) { // Enter your logic here... } ``` Examples: ```code Input: ' Codetisan ' Output: 'Codetisan' Explanation: There are no spaces available anywhere in the output string. ``` ```code Input: 'Binary code: 0 1' Output: 'Binarycode:01' Explanation: Binary is followed by a newline, so the newline must also be removed. ``` Submission: ```javascript const noSpace = (str) => str.replace(/ |\n/ig, ''); ``` ## Append a new element to a given array Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/ckw5wy4tv00740wmd40zbp4jf/javascript/append-a-new-element-to-a-given-array) Write a JavaScript function to accept 2 parameters, an array and a new value. Append the new value to the given array and return the updated array. Sample Code: ```javascript function append(arr, value) { // Enter your logic here... } ``` Examples: ```code Input: ['hello','world'], 'hi' Output: ['hello','world','hi'] Explanation: Add the new value to the end of an given array. ``` ```code Input: [1,2,3], 4 Output: [1,2,3,4] Explanation: Add the new value to the end of an given array. ``` Submission: ```javascript const append = (arr, value) => [...arr, ...[value]]; ``` ## Capitalize the first character Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/ckw0qu68o00460wl0219xeetk/javascript/capitalize-the-first-character) Capitalize the first character of each word of a given string. Sample Code: ```javascript function capitalize(s) { // Enter your logic here... } ``` Examples: ```code Input: 'hello world' Output: 'Hello World' Explanation: Capitalize letter h and w. ``` ```code Input: '3 cars' Output: '3 Cars' Explanation: Capitalize letter c. ``` Submission: ```javascript const capitalize = (s) => s.split(' ').map((e) => e.substr(0, 1).toUpperCase() + e.substr(1)).join(' '); ``` ## Find the sum of elements in a given integer array Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/ckw4rczz704250wl3nijw5jm4/javascript/find-the-sum-of-elements-in-a-given-integer-array) Find the sum of elements in a given integer array. Sample Code: ```javascript function sum(s) { // Enter your logic here... } ``` Examples: ```code Input: [1,2,3,4,5] Output: 15 Explanation: 1 + 2 + 3 + 4 + 5 = 15 ``` ```code Input: [-10, 10, 1, -1, 100] Output: 100 Explanation: -10 + 10 + 1 - 1 + 100 = 100 ``` Submission: ```javascript const sum = (s) => s.reduce((a, b) => a + b); ``` ## Flattening sub-arrays in an Array Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1u3p20h00250wmmrt280j4x/javascript/reducing-sub-arrays) Given an array with multiple subarray elements, the final function needs to flatten the array to ensure that the array does not contain subarrays. Sample Code: ```javascript function flatArr(arr) { // Enter your logic here... } ``` Examples: ```code Input: [1,2,3,[4,5],['numbers']] Output: [1,2,3,4,5,'numbers'] Explanation: The sub-array elements have been flattened. ``` ```code Input: [1,[2,[3],4],5] Output: [1,2,3,4,5] Explanation: The sub-array elements have been flattened. ``` Submission: ```javascript const flatArr = (arr) => arr.flat(Infinity); ``` ## Adding element to the beginning of an Array Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1tbqbtu02440wijy6urxnaz/javascript/adding-element-to-the-beginning-of-an-array) Given an array and a value, insert the value to the beginning of the array. Sample Code: ```javascript function addEle(arr,ele) { // Enter your logic here... } ``` Examples: ```code Input: [1,2,3],0.9 Output: [0.9,1,2,3] Explanation: Element 0.9 has been added to the array at index 0. ``` ```code Input: [1,2,3],[0,'0.5'] Output: [[0,'0.5'],1,2,3] Explanation: Element [0,'0.5'] has been added to the array at index 0. ``` Submission: ```javascript const addEle = (arr, ele) => { arr.unshift(ele); return arr; } ``` ## Number to string Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1q93u0q18120wl4k5joscoq/javascript/number-to-string) Return the given number in a string format. Sample Code: ```javascript function numToStr(num) { // Enter your logic here... } ``` Examples: ```code Input: 0 Output: '0' Explanation: Number in string format. ``` ```code Input: -99.99 Output: '-99.99' Explanation: Number in string format. ``` Submission: ```javascript const numToStr = (num) => '' + num; ``` ## Round down Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1rs1yls03830wl0w1a88a9n/javascript/round-down) Round down the given number. Sample Code: ```javascript function roundDown(num) { // Enter your logic here... } ``` Examples: ```code Input: 9.9 Output: 9 Explanation: 9 is the result of rounding down 9.9. ``` ```code Input: 0.1 Output: 0 Explanation: 0 is the result of rounding down 0.1. ``` Submission: ```javascript const roundDown = (num) => Math.floor(num); ``` ## Duplicate elements Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1p4qfy200250wkw6u88w76l/javascript/double-elements) Return the given string with 2 occurrences for each elements. Sample Code: ```javascript function doubleUp(str) { // Enter your logic here... } ``` Examples: ```code Input: 'Hello World' Output: 'HHeellllloo WWoorrlldd' Explanation: Every Elements have its own duplication. ``` ```code Input: 'ಠ_ಠ' Output: 'ಠಠ__ಠಠ' Explanation: Symbols are also being duplicated. ``` Submission: ```javascript const doubleUp = (str) => str.split('').map((e) => e + e).join(''); ``` ## Speed of light Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1ow5f0i01060vjpe4jeiofu/javascript/speed-of-light) Return true if the given number is equivalent to 299,792,458. Otherwise false. Sample Code: ```javascript function lightSpeed(num) { // Enter your logic here... } ``` Examples: ```code Input: 299792458 Output: true Explanation: 299,792,458 m/s is the speed of light, according to Google. ``` ```code Input: 323232 Output: false Explanation: 299,792,458 m/s is the speed of light, according to Google. ``` Submission: ```javascript const lightSpeed = (num) => num === 299792458; ``` ## Extract the first string element Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1q67cvk10080wl889dviekn/javascript/first-letter) Return the first letter of the given string. Sample Code: ```javascript function firstLetter(str) { // Enter your logic here... } ``` Examples: ```code Input: 'Codetisan' Output: 'C' Explanation: 'C' element has an index value of 0. ``` ```code Input: ' Javascript' Output: ' ' Explanation: ' ' element has an index value of 0. ``` Submission: ```javascript const firstLetter = (str) => str.split('')[0]; ``` ## 100 plus Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1m9km7e03970wmmabksxyh3/javascript/100-plus) A function that receives two numbers, return true if the summation of the numbers is less than or equal to 100. Sample Code: ```javascript function hundredPlus(num1,num2) { // Enter your logic here... } ``` Examples: ```code Input: 1,100 Output: false Explanation: 1+100 equals to 101 which is not less than 100 or equal to 100. ``` ```code Input: 50,50 Output: true Explanation: 50+50 is equal to 100. ``` Submission: ```javascript const hundredPlus = (num1, num2) => num1 + num2 === 100; ``` ## Printing the next character Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1nqp4bq00370vkzzdpq31hj/javascript/printing-the-next-character) Given a string, replace every letter with its subsequent letter. For example, the letter A will be converted to letter B. Sample Code: ```javascript function nextTerm(str) { // Enter your logic here... } ``` Examples: ```code Input: 'abcd' Output: 'bcde' Explanation: The subsequent letter 'a' is 'b'. ``` ```code Input: 'bncd' Output: 'code' Explanation: The subsequent letter 'b' is 'c'. ``` Submission: ```javascript const nextTerm = (str) => str.split('').map((e) => String.fromCharCode(e.charCodeAt() + 1)).join(''); ``` ## Find the largest of three given integers Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/ckvxx42mb000012mgbqbxmorg/javascript/find-the-largest-of-three-given-integers) Write a JavaScript function to accept 3 integers, find the largest of three given integers. Sample Code: ```javascript function findTheLargest(a, b, c) { // Enter your logic here... } ``` Examples: ```code Input: 1,2,3 Output: 3 Explanation: Integer 3 is the largest of three given integers. ``` ```code Input: 100,-200,50 Output: 100 Explanation: Integer 100 is the largest of three given integers. ``` Submission: ```javascript const findTheLargest = (a, b, c) => Math.max(a, b, c); ``` ## -Counting steps Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1qml7ai01210wievos5bezf/javascript/counting-steps) Return an array of numbers starting with 1 up to the given number. Round up the number if the given number has decimal places. Sample Code: ```javascript function myLegHurts(num) { // Enter your logic here... } ``` Examples: ```code Input: 10 Output: [1,2,3,4,5,6,7,8,9,10] Explanation: Each numbers have been increased by 1 up to number 10. ``` ```code Input: 5.5 Output: [1,2,3,4,5,6] Explanation: Each numbers have been increased by 1 up to number 6. ``` Submission: ```javascript const myLegHurts = (num) => { const arr = []; for (let i = 1; i <= Math.ceil(num); i ++) { arr.push(i); } return arr; } ``` ## Introduce yourself Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1xmtfsg03250wl8ss9l900q/javascript/introduce-yourself) Build and return a sentence using the given Object as shown in the example. Sample Code: ```javascript function whatAmI(obj) { // Enter your logic here... } ``` Examples: ```code Input: {name:‘human’,lang:’English‘} Output: ’I am human and I speak English.‘ Explanation: ‘human’ and ‘English’ are the first and second values of the object respectively. ``` ```code Input: {name:‘another human’,lang:‘Javascript’} Output: ‘I am another human and I speak Javascript.’ Explanation: ‘another human’ and ‘Javascript’ are the first and second values of the object respectively. ``` Submission: ```javascript const whatAmI = (obj) => `I am ${obj.name} and I speak ${obj.lang}.` ``` ## Keywords detector II Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1vvv12n02160wl11wd2tm4a/javascript/keywords-detector-ii) Given a string and a keyword, return the keyword index value as shown in the examples. Sample Code: ```javascript function wordFinder(strs,str) { // Enter your logic here... } ``` Examples: ```code Input: 'What did the ocean say to the beach','beach' Output: 'beach found at index 7.' Explanation: The element 'beach' has an index value of 7. ``` ```code Input: 'Nothing, it just waved','🐳' Output: '🐳 not found.' Explanation: The element '🐳' was not found in the input string. ``` Submission: ```javascript const wordFinder = (strs, str) => strs.indexOf(str) === -1 ? `${str} not found.` : `beach found at index ${strs.split(' ').indexOf(str)}.`; ``` ## Creating subarrays Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1ugnn2500330xml55rkeh3t/javascript/creating-nested-arrays) The function will divide the original array into a number of sub-arrays according to the provided number N, each sub-array should have N elements. Sample Code: ```javascript function arrNested(arr,n) { // Enter your logic here... } ``` Examples: ```code Input: [1,2,3,4,5,6],2 Output: [[1,2],[3,4],[5,6]] Explanation: Each sub-arrays have 2 elements. ``` ```code Input: [1,2,3,4,5,6],3 Output: [[1,2,3],[4,5,6]] Explanation: Each sub-arrays have 3 elements. ``` Submission: ```javascript const arrNested = (arr, n) => { let res = []; while (arr.length) { res.push(arr.splice(0, n)); } return res; } ``` ## Is remainder equals to 0 Challenge here:[Coding problems | Codetisan](https://www.codetisan.com/en/code/cl1uatlq600800vl8qvhq35nc/javascript/getting-a-0-remainder) The given parameters are n1 and n2, the function needs to judge whether there is a remainder after n1 is divided by n2. Sample Code: ```javascript function isDivisible(n1,n2) { // Enter your logic here... } ``` Examples: ```code Input: 1,2 Output: false Explanation: 1 divided by 2 has a remainder, returns false. ``` ```code Input: 2,1 Output: true Explanation: 2 divided by 1 has a remainder of 0 and returns true. ``` Submission: ```javascript const isDivisible = (n1, n2) => n1 % n2 === 0; ```