Skip to content

Instantly share code, notes, and snippets.

View vldvel's full-sized avatar

Vlad vldvel

  • Amsterdam
View GitHub Profile
@vldvel
vldvel / palindrome.js
Last active August 22, 2020 14:25
JavaScript is Palindrome
const string1 = 'level';
const string2 = 'Le, vel.';
const isPalindrome = (stringToTest1, stringToTest2) => {
const stringToTestTransformed1 = stringToTest1
.replace(/[^\w]/gi, '') // replace all non-lettter characters
.toLowerCase(); // make all characters lower cased
const stringToTestTransformedAndReversed2 = stringToTest2
.replace(/[^\w]/gi, '')
const string1 = 'level';
const string2 = 'house';
const isPalindrome = stringToTest => stringToTest === stringToTest.split('').reverse().join('');
isPalindrome(string1); // true
isPalindrome(string2); // false
const string1 = 'level';
const string2 = 'Le, vel.';
const isPalindrome = stringToTest => {
const stringTransformed = stringToTest
.replace(/[^\w]/gi, '') // replace all non-letter characters
.toLowerCase(); // make all characters lower cased
return stringTransformed === stringTransformed.split('').reverse().join('');
}
@vldvel
vldvel / indexOf.js
Last active February 25, 2018 07:14
if (s.indexOf('PM') > -1) // then do smth with PM
else // then do some other thing with AM
const arr = s.slice(0,8).split(':');
// '00:00:00AM' -> ['00', '00', '00']
// PM case
if (arr[0] == 12) { // as 12 is the string I use ==, but you can rewrite it like === '12'
arr[0] = '12';
} else {
arr[0] = Number(arr[0]) + 12; // if we add number to string we will get new string like '1312'
}
// AM case
if (arr[0] == 12) {
arr[0] = '00';
const arr = s.slice(0,8).split(':');
arr[0] = (s.indexOf('PM') > -1) ?
(arr[0] == 12 ? '12' : Number(arr[0]) + 12) :
(arr[0] == 12 ? '00' : arr[0]);
const arr = s.slice(0,8).split(':');
arr[0] = (s.indexOf('PM') > -1) ?
(arr[0] == 12 ? '12' : Number(arr[0]) + 12) :
(arr[0] == 12 ? '00' : arr[0]);
return arr.join(':');
.blured-circle {
filter: blur(1.2vmax);
}
.blurred-wrapper {
filter: contrast(7);
}