Skip to content

Instantly share code, notes, and snippets.

View MosesNjs's full-sized avatar

Moses Sopuluchukwu Njoku MosesNjs

View GitHub Profile
@MosesNjs
MosesNjs / Learnable 23 Technical Test
Last active December 10, 2023 15:47
Learnable 23 Technical Test. Moses Njoku
function nth_most_rate_signature(list, n)
{
list.sort();
let min_count = n+1, res = -1;
let curr_count = 1;
for (let i = 1; i < n; i++)
{
if (list[i] == list[i - 1])
@MosesNjs
MosesNjs / MastercardValidation.js
Created January 15, 2023 21:06
This is a JavaScript program for validating a MasterCard Number. To test, run the code and reply the prompt with a 16 digit number that starts with 51-55. See comment at bottom for description of regEx pattern.
"use strict"
const prompt = require("prompt-sync")({sigint: true})
// This Regular Expression matches for a valid Mastercard number. Mastercard numbers start with a 51-55 and have a total of 16 digits.
const RegEx = /^5[1-5]\d{14}$/
// This Function prompts for a Mastercard number and begins validation.
const validate = (cardNo) => {