Skip to content

Instantly share code, notes, and snippets.

View Shaikot007's full-sized avatar

Shaikot Shaikot007

  • Dhaka, Bangladesh
View GitHub Profile
@Shaikot007
Shaikot007 / Palindrome checker
Last active January 5, 2023 21:39
Palindrome checker. (freeCodeCamp JavaScript algorithms and data structures challenge)
function palindrome(str) {
var newstr = str.replace(/[\W\_]/gi, "").toLowerCase();
array = newstr.split("").reverse().join("");
if (newstr === array) {
return true;
}
else return false;
};
@Shaikot007
Shaikot007 / Roman numeral converter
Last active July 12, 2021 11:26
Roman numeral converter. (freeCodeCamp JavaScript algorithms and data structures challenge)
function convertToRoman(num) {
var englishArray = [1000000, 500000, 100000, 50000, 10000, 5000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
var romanArray = ["M̄", "D̄", "C̄", "L̄", "X̄", "V̄", "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"];
var Roman = "";
for (var i=0; i<=englishArray.length; i++) {
while (num%englishArray[i] < num) {
Roman += romanArray[i];
@Shaikot007
Shaikot007 / Caesars cipher
Last active July 12, 2021 11:30
Caesars cipher. (freeCodeCamp JavaScript algorithms and data structures challenge)
function rot13(str) {
newstr = str.split("");
var finalstr = newstr.map(function(letter) {
lettervalue = letter.charCodeAt(0);
if (lettervalue < 65 || lettervalue > 90) {
return String.fromCharCode(lettervalue);
}
@Shaikot007
Shaikot007 / Telephone number validator
Last active July 12, 2021 11:27
Telephone number validator. (freeCodeCamp JavaScript algorithms and data structures challenge)
function telephoneCheck(str) {
var regex1 = /^[0-9]{3}[-][0-9]{3}[-][0-9]{4}$/;
var regex2 = /^[(][0-9]{3}[)][0-9]{3}[-][0-9]{4}$/;
var regex3 = /^[(][0-9]{3}[)][\s][0-9]{3}[-][0-9]{4}$/;
var regex4 = /^[0-9]{3}[\s][0-9]{3}[\s][0-9]{4}$/;
var regex5 = /^[0-9]{10}$/;
var regex6 = /^[1]{1}[\s][0-9]{3}[\s][0-9]{3}[\s][0-9]{4}$/;
var regex7 = /^[1]{1}[\s][0-9]{3}[-][0-9]{3}[-][0-9]{4}$/;
var regex8 = /^[1]{1}[\s][(][0-9]{3}[)][\s][0-9]{3}[-][0-9]{4}$/;
var regex9 = /^[1]{1}[(][0-9]{3}[)][0-9]{3}[-][0-9]{4}$/;
@Shaikot007
Shaikot007 / Cash register
Last active June 11, 2024 06:16
Cash register. (freeCodeCamp JavaScript algorithms and data structures challenge)
function checkCashRegister(price, cash, cid) {
var change = cash - price;
var coinValues = [
{ name: 'ONE HUNDRED', val: 100.00 },
{ name: 'TWENTY', val: 20.00 },
{ name: 'TEN', val: 10.00 },
{ name: 'FIVE', val: 5.00 },
{ name: 'ONE', val: 1.00 },
{ name: 'QUARTER', val: 0.25 },