Skip to content

Instantly share code, notes, and snippets.

View vijayjangid's full-sized avatar
:octocat:
figuring out...

Vijay Jangid vijayjangid

:octocat:
figuring out...
View GitHub Profile
@vijayjangid
vijayjangid / object def.js
Created October 4, 2023 05:17
Object def
let count;
if(count==1 && count==2 && count== 3) {
console.log('You did a miracle!");
} else {
console.log('try again');
}
@vijayjangid
vijayjangid / signin-up ui
Created October 3, 2023 09:47
SignIn/SignUp UI
https://screenshots.codesandbox.io/5xdnb/34.png
@vijayjangid
vijayjangid / fishinghook.md
Last active September 29, 2023 05:51
React Fishing Hook

Given a Pond (array of Fishes) where the Fish object is as below:

// Fish
{
name: string,
size: 'small'|'medium'|'large'
hungry: boolean
}

const pond = [
@vijayjangid
vijayjangid / gist:b36ca96efd96eb7bf69686cf8fa8c38a
Last active May 31, 2021 10:26
React Interview Questions

FOOD TRANSLATOR

Convert text into delicious Food emoji 😋

- Add an input control (input/textarea) to allow entering text.
- On text change, a food emoji should be rendered for each WORD in the text.
  - If the word length is ODD, print a PIZZA emoji 🍕
  - If the word length is EVEN, print a BURGER emoji 🍔
  - Each emoji should be separated by a <space>.

Example

input : I love Pizza and Burger
@vijayjangid
vijayjangid / gist:268a990dc38443df0d208a0cf375c0ee
Created February 9, 2021 04:46
Simple flexbox 2x2 matrix
/* HTML */
<div class="container">
<div class="tile">1</div>
<div class="tile">2</div>
<div class="tile">3</div>
<div class="tile">4</div>
</div>
/* CSS */
.container {
@vijayjangid
vijayjangid / inf-curried-sum.js
Created June 15, 2019 06:47
infinite curried function for sum
function f (input, sum = 0) {
if(!input) {
return sum;
}
else {
return function(nextInput) {
sum += input;
return f(nextInput, sum);
}
}
@vijayjangid
vijayjangid / custom-async-order.js
Last active May 7, 2021 16:32
Async job in custom order
/*
H ~~~~ ->
A -> B ->
C -> D
H: high priority long task, should start in parallel to A
A: first task
B: should start once A is finished
C: should start once B & H is finished
D: should start once C is finished
@vijayjangid
vijayjangid / flatten.js
Created June 4, 2019 13:12
JS flatten array using ES6
_flatten = input =>
input.reduce((acc, curr) =>
Array.isArray(curr) ? [...acc, ..._flatten(curr)] : [...acc, curr], []);
// test
_flatten([[1,2],3,4,[5,[6,7],8],[9,[10,[11]]]]); // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
@vijayjangid
vijayjangid / fetch-chunked.js
Last active September 14, 2018 07:04 — forked from jfsiii/fetch-chunked.js
Quick example of using fetch to parse a chunked response
var chunkedUrl = 'https://jigsaw.w3.org/HTTP/ChunkedScript';
fetch(chunkedUrl)
.then(processChunkedResponse)
.then(onChunkedResponseComplete)
.catch(onChunkedResponseError)
;
function onChunkedResponseComplete(result) {
console.log('-----------all done!----------');
console.log(result);