This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sortBy(arr, fn= ()=>{}) { | |
const array = [...arr]; | |
for (let i=0; i<array.length; i++) { | |
for (let j=i+1;j<array.length;j++){ | |
if (array[j] < array[i]) { | |
const temp = array[i]; | |
array[i] = array[j]; | |
array[j] = temp; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Definition of Leader: Any Element which is greater than all the values to its right | |
function findLeadersInArray(arr) { | |
const leaders = []; | |
arr.forEach((a, i)=> { | |
if (i=== arr.length-1) { | |
leaders.push(a); | |
return leaders; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cycle(a, b) { | |
if (a.length !== b.length) return 0; | |
const arr = a.split(''); | |
const temp = [...arr]; // i am copying the array. | |
let count = 0; | |
for(let e of arr) { | |
count += 1; | |
console.log(temp.join('')); | |
const firstElement = temp.shift(); // this removes the 1st element of the array | |
temp.push(firstElement); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// when T is any|unknown, Y is returned, otherwise N | |
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N; | |
// when T is never, Y is returned, otherwise N | |
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N; | |
// when T is a tuple, Y is returned, otherwise N | |
// valid tuples = [string], [string, boolean], | |
// invalid tuples = [], string[], (string | number)[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sum = (a) => (b) => b === undefined ? a : sum(a+b); | |
const arr = [] | |
arr[0] = sum(1)(2)(3)(); // output: 6 | |
arr[1] = sum(1)(2)(3)(1)(1)(2)(2)(10)(); // output: 22 | |
console.log(arr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function useState(initVal) { | |
let _val = initVal; | |
let state = () => _val; | |
const setState = (newVal) => _val = newVal; | |
return [state, setState] | |
} | |
const [c, setC] = useState(1); | |
console.log(c()); | |
setC(2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Array<T> { | |
customEvery(callback: (each: T, index?: number, array?: Array<T>) => boolean): boolean; | |
} | |
Array.prototype.customEvery = function(callback) { | |
let res= [] | |
for (let i = 0; i < this.length; i++) res.push(callback(this[i], i, this)); | |
return res.includes(false) ? false : true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"basics": { | |
"name": "Rajalakshmi Venkatramani", | |
"label": "Senior Executive Human Resources", | |
"picture": "", | |
"email": "[email protected]", | |
"phone": "957-808-0626", | |
"website": "", | |
"summary": "Experienced Human Resource skilled in Recruitment, Administration, Performance Management & Payroll.\nGoals: Want to work in an organization where I get opportunity to groom & nurture myself. I want to work in an organization by integrating my goals with the organizational goal by using win - win strategy\nSpecialties: Strong in communication, good in interpersonal relationship and overall knowledge in HR \n", | |
"location": { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"meta": { | |
"theme": "elegant" | |
}, | |
"basics": { | |
"name": "Vishnu Roshan", | |
"label": "Senior Software Engineer at Sedin Technologies", | |
"picture": "", | |
"email": "[email protected]", | |
"phone": "+91 99520 29597", |