Skip to content

Instantly share code, notes, and snippets.

View erhanyasar's full-sized avatar
🏠
Working from home

Erhan Yaşar erhanyasar

🏠
Working from home
View GitHub Profile
@erhanyasar
erhanyasar / formControl.js
Last active March 9, 2023 14:04
A gist to validate form inputs
$(document).ready(function() {
let f1err = 0,
f2err = 0,
f3err = 0,
date = new Date();
$("#sendBTN").click(function() {
if (($("#username").val() == "") || ($("#phone").val() == "")) {
f1err = 1;
if ($("#username").val() == "") {
@erhanyasar
erhanyasar / barcodeReader.js
Last active March 9, 2023 14:00
A sample integration to use related barcode applications in order to read QR data
function tryAppStore() {
setTimeout(function() {
window.location = "https://appsto.re/tr/6XPCz.i";
}, 25);
window.location="Barcode://scan/";
}
function tryGoogleStore() {
setTimeout(function() {
window.location = "https://play.google.com/store/apps/details?id=com.google.zxing.client.android&hl=en";
@erhanyasar
erhanyasar / findMissing
Last active March 9, 2023 14:11
Some Quiz Questions Solved
let A = [4,12,9,5,6,1],
B = [4,9,12,6];
function findMissing(A, B){
let missingElements = [];
for (var i=0; i<A.length; i++){
for (var j=0; j<B.length; j++){
if (A[i] == B[j])
break;
@erhanyasar
erhanyasar / Converting Object to an Array
Last active March 9, 2023 14:21
Simple Quiz Solutions
const object = {
'1': 30,
'2': 58
};
function objectToArrConverter (obj) {
if (Object.entries(obj).length === 0)
return [];
else {
let arr = Object.entries(obj);
const solution = (numbers) => {
let maxNumber = 0;
for (let i=0; i<numbers.length; i++){
if (numbers.length < 1)
return maxNumber;
if (numbers[i] > maxNumber)
maxNumber = numbers[i];
}
return maxNumber;
const dataArr = [
"B$u$i$ld",
"$t$$h$e",
"N$e$x$t",
"E$$ra",
"$$o$f$",
"S$$of$t$wa$r$e",
"De$$ve$l$op$me$n$t",
];
let numbersArr = [4, 6, 7, 9, 12];
function findSecondBiggestNumber(numbers) {
numbers.sort((a, b) => a - b);
return numbers[numbers.length - 2];
}
// console.log(findSecondBiggestNumber(numbersArr));
let strForReverse = "Erhan";
// 1. Write a function for strings that return a string that's repeating the string
// for a given integer number for instance, given `"hello".repeatify(3)` expression
// should return "hello, hello, hello" as an output
String.prototype.repeatify = function (param) {
let result = "";
for (let i = 0; i < param; i++) result += `, ${this}`;
return result.slice(1).trim();
};
@erhanyasar
erhanyasar / gist:eb7a4e7de44ef1101cd6032468c03f4e
Created July 24, 2023 14:37
A function returns depth for a given number under given conditions
/*
The depth of an integer n is defined to be how many multiples of n it is necessary to compute
before all 10 digits have appeared at least once in some multiple.
Example: let see n=42
Multiple value digits comment
42*1 42 2,4
42*2 84 8 4 existed
42*3 126 1,6 2 existed
/*
Write a Function According to Given Brief:
The MEX number of a non-negative set of numbers is the smallest non-negative number that is not present in the set.
For example, MEX([1, 3, 10]) = 0, and MEX([0, 1, 2, 8]) = 3.
Your task is to take a given array arr of length num and remove the minimum number of elements from it so that,
the MEX value of the modified array is not equal to the MEX value of the original array.
- It should return the minimum number of elements that needed to be removed from the array