Skip to content

Instantly share code, notes, and snippets.

View kingstenbanh's full-sized avatar

Kingsten Banh kingstenbanh

View GitHub Profile
8539734222673567065463550869546574495034888535765114961879601127067743044893204848617875072216249073013374895871952806582723184
function multiply(x, y) {
if (BigInt(x) < 10n && BigInt(y) < 10n) {
return BigInt(x) * BigInt(y);
}
const xHalf = Math.floor(x.length / 2);
const yHalf = Math.floor(y.length / 2);
const a = String(x).substr(0, xHalf);
const b = String(x).substr(xHalf);
const number1 = 3141592653589793238462643383279502884197169399375105820974944592;
const number2 = 2718281828459045235360287471352662497757247093699959574966967627;
// JS
const countButton = document.querySelect('.count);
const helloButton = document.querySelect('.hello);
function counting() {
let count = 0;
setInterval(function() {
count += 1;
console.log(count);
}, 1000)
@kingstenbanh
kingstenbanh / isPalindrome.js
Last active February 19, 2019 21:42
Palindrome for number
function isPalindrome(number) {
let divisor = 1;
// Find the appropriate divisor
// to extract the leading digit
while (number / divisor >= 10) {
divisor *= 10;
}
while (number !== 0) {
@kingstenbanh
kingstenbanh / isPalindrome.js
Last active February 19, 2019 21:20
Palindrome for sentences
function isPalindrome(sentence) {
sentence = sentence.toLowerCase().replace(/[^\w]/gi, "");
const n = sentence.length;
const halfLength = Math.floor(sentence.length / 2);
for (let i = 0; i < halfLength; i++) {
if (sentence[i] !== sentence[n - 1 - i]) {
return false;
}
}
@kingstenbanh
kingstenbanh / isPalindrome.js
Created February 19, 2019 21:03
Palindrome for Word - Recursive Approach
function isPalindrome(word, start = 0, end = word.length - 1) {
// If there is only one character
if (start === end) {
return true;
}
// If first and last characters don't match
if (word[start] !== word[end]) {
return false;
}
@kingstenbanh
kingstenbanh / palindrome.js
Last active February 19, 2019 20:52
Palindrome for Words
function isPalindrome(word) {
word = word.toLowerCase();
const n = word.length;
const halfLength = Math.floor(word.length / 2);
for (let i = 0; i < halfLength; i++) {
if (word[i] !== word[n - 1 - i]) {
return false;
}
}
public filterTeamList(authService: AuthService, data) {
let filtered = data
.map((item) => {
const { userService, getUserID, logger } = authService;
const userId = getUserId();
const {
user_id,
approver,
assigned_to_id,
draft,