Skip to content

Instantly share code, notes, and snippets.

View deschantkn's full-sized avatar
🚀

Deschant Kounou deschantkn

🚀
View GitHub Profile
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) {
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;
@deschantkn
deschantkn / isPalindrome.js
Last active February 28, 2020 16:07
Check if a word is a Palindrome
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;