This file contains hidden or 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
| function countApplesAndOranges(s, t, a, b, apples, oranges) { | |
| let noOfApples = 0; | |
| let noOfOranges = 0; | |
| const applePositions = apples.map(apple => apple + a); | |
| const orangePositions = oranges.map(orange => orange + b); | |
| console.log(applePositions, orangePositions); | |
| for (let i = 0; i < applePositions.length; i++) { | |
| if (applePositions[i] >= s && applePositions[i] <= t) { |
This file contains hidden or 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
| function timeConversion(s) { | |
| let [hour, minute, seconds] = s.split(':'); | |
| hour = parseInt(hour); | |
| const secs = seconds.substring(0, 2); | |
| if (hour === 12 && minute <= 59 && seconds.endsWith('AM')) { | |
| hour = parseInt(hour) - 12 === 0 ? '00' : parseInt(hour) - 12; | |
| return `${hour}:${minute}:${secs}`; | |
| } else if (seconds.endsWith('PM') && hour >= 1 && hour <= 11 && parseInt(minute) <= 59) { | |
| hour = parseInt(hour) === 12 ? '12' : parseInt(hour) + 12; |
This file contains hidden or 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
| function isPalindrome(word) | |
| { | |
| word = word.toLowerCase(); | |
| const length = word.length; | |
| let check = false; | |
| if (word % 2 === 0) { | |
| for (let i = 0; i < length; i++) { | |
| if (word[i] === word[length - i]) { | |
| check = true; |