Skip to content

Instantly share code, notes, and snippets.

View arrbxr's full-sized avatar
🎯
Focusing

Abhishek Raj Ravi arrbxr

🎯
Focusing
  • Aryabhatta Knowledge University, Bihar
  • Patna India
  • X @arrbxr
View GitHub Profile
@arrbxr
arrbxr / index.js
Created September 12, 2018 21:21
matrix spiral problem created by arrbxr - https://repl.it/@arrbxr/matrix-spiral-problem
function matrix(n) {
let result = [];
for(let i = 0; i < n; i++) {
result.push([]);
}
let counter = 1;
let startColun = 0;
@arrbxr
arrbxr / index.js
Created September 11, 2018 22:54
integer sequence created by arrbxr - https://repl.it/@arrbxr/integer-sequence
function sequence(seq) {
var bad = 0
for(var i=1;i<seq.length;i++) {
if(seq[i]<=seq[i-1]) {
bad++
if(bad>1) {
return false
}
if(seq[i]<=seq[i-2]&&seq[i+1]<=seq[i-1]) {
return false
@arrbxr
arrbxr / index.js
Created August 27, 2018 19:46
stack of javascript created by arrbxr - https://repl.it/@arrbxr/stack-of-javascript
// Show the complete implementation
// of the stack class
function Stack() {
this.dataStore = [];
this.top = 0;
this.push = push;
this.pop = pop;
this.peek = peek;
this.clear = clear;
@arrbxr
arrbxr / index.js
Created August 27, 2018 14:48
make array consectrive created by arrbxr - https://repl.it/@arrbxr/make-array-consectrive
/*
let a = [];
const bubbleSort = (arr) => {
let newArr = arr.sort((a,b) => a - b);
for(let i = newArr[0]; i <= newArr[newArr.length - 1]; i++){
a.push(i);
}
return a.length - newArr.length;
}
@arrbxr
arrbxr / index.js
Created August 13, 2018 20:41
Functional Programming in javaScript created by arrbxr - https://repl.it/@arrbxr/Functional-Programming-in-javaScript
const prepareTea = () => "greenTea";
const getTea = (numOfCups) =>{
const teaCups = [];
for(let cups = 1; cups < numOfCups; cups++){
const teaCup = prepareTea();
teaCups.push(teaCup);
@arrbxr
arrbxr / index.js
Created August 13, 2018 07:22
Truncate a String created by arrbxr - https://repl.it/@arrbxr/Truncate-a-String
function truncateString(str, num) {
// Clear out that junk in your trunk
return str.length > num ? str.slice(0, num).concat('...') : str;
}
truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and".length);
@arrbxr
arrbxr / index.js
Created August 12, 2018 23:22
confirm the ending created by arrbxr - https://repl.it/@arrbxr/confirm-the-ending
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if(str.slice(str.length-target.length) === target){
return true;
}
else
return false;
@arrbxr
arrbxr / index.js
Created August 12, 2018 23:22
confirm the ending created by arrbxr - https://repl.it/@arrbxr/confirm-the-ending
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
if(str.slice(str.length-target.length) === target){
return true;
}
else
return false;
@arrbxr
arrbxr / index.js
Created August 8, 2018 17:57
Compare the Triplets created by arrbxr - https://repl.it/@arrbxr/Compare-the-Triplets
function compareTriplets(a,b){
let alice = 0, bob = 0;
let result = [];
for(var i = 0; i < 3; i++){
if(a[i] > b[i]){
alice++;
}
else if(a[i] < b[i]){
bob++;
}
class Book {
constructor(author){
this._author = author;
}
//getter
get writer(){
return this._author;
}