Skip to content

Instantly share code, notes, and snippets.

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

Damir Aushenov ecaepsey

🏠
Working from home
  • Keremet Bank
  • Kyrgyzstan
View GitHub Profile
@ecaepsey
ecaepsey / letterCount.js
Last active February 9, 2017 09:15
singleLetterCount
function singleLetterCount(word, letter) {
var count = 0;
for(var i = 0; i < word.length; i++) {
if(word[i].toUpperCase() == letter.toUpperCase()) {
count++;
}
}
return count;
}
@ecaepsey
ecaepsey / arrayManipulation.js
Created February 9, 2017 09:41
just having fun with array
function arrayManipulation(arr, command, location, value) {
if(command == "remove" && location =="end") {
return arr.pop();
} else if (command =="remove" && location =="beginning") {
return arr.shift();
} else if(command ="add" && location =="beginning") {
arr.unshift(value)
return arr
function findall(a, x) {
var results = [], // The array of indexes we'll return
len = a.length, // The length of the array to be searched
pos = 0; // The position to search from
while(pos < len) { // While more elements to search...
pos = a.indexOf(x, pos); // Search
if (pos === -1) break; // If nothing found, we're done.
results.push(pos); // Otherwise, store index in array
pos = pos + 1; // And start next search at next element
}
const hummus = function(factor) {
  const ingredient = function(amount, unit, name) {
    let ingredientAmount = amount * factor;
    if (ingredientAmount > 1) {
      unit += "s";
    }
    console.log(`${ingredientAmount} ${unit} ${name}`);
  };
  ingredient(1, "can", "chickpeas");
  ingredient(0.25, "cup", "tahini");
mongod --dbpath "C:\Program Files\MongoDB\data\db"
@ecaepsey
ecaepsey / index.js
Created June 30, 2018 15:11
sorting
m.sort(function (a, b) {
if (a === b) {
return 0;
}
if (typeof a === typeof b) {
return a < b ? -1 : 1;
}
return typeof a < typeof b ? -1 : 1;
});
@ecaepsey
ecaepsey /  index.js
Created January 20, 2019 12:31
SUM OF PRIME
function sumPrimes(num) {
var count = []
for(var j = 0; j < num; j++) {
if(isPrime(j)) {
count.push(j)
console.log(count)
}
rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/metro-* && rm -rf $TMPDIR/haste-* && watchman watch-del-all && rm -rf node_modules && yarn install && npm start -- --reset-cache
@ecaepsey
ecaepsey / .js
Created March 6, 2019 05:04
Format SUm
var input = 222323.34343;
function formatSum(sum) {
if(Number.isInteger(sum)) {
return sum
}
var beforeDot = /[^.]*/.exec(sum)[0]
var afterDot = /(?<=\.).*/.exec(sum)[0]
return beforeDot + ',' + afterDot
const findSum = (arr, val) => {
for (let i = 0; i < arr.length; i++) {
for (let j = 0; j < arr.length; j++) {
if (i !== j && arr[i] + arr[j] === val) {
return true;
};
};
};
return false;
};