Skip to content

Instantly share code, notes, and snippets.

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

Pratik Dev Das pratikdevdas

🏠
Working from home
View GitHub Profile
@pratikdevdas
pratikdevdas / conditionalRendering.js
Created December 26, 2021 13:00
conditional rendering must remember
const addBlog = () => {
const newBlog = {
title: newTitle,
author: newAuthor,
url: newUrl,
}
if(newBlog.title.length<4)
{
return console.log('give longer value')
@pratikdevdas
pratikdevdas / bookmarks.html
Created December 20, 2021 02:51
Brave Bookmarks
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 ADD_DATE="1639744473" LAST_MODIFIED="1639967469" PERSONAL_TOOLBAR_FOLDER="true">Bookmarks</H3>
<DL><p>
@pratikdevdas
pratikdevdas / reduxcounter.js
Created December 9, 2021 08:46
Simple counter app with redux
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore } from 'redux';
const counterReducer = (state = 0,action) => {
switch(action.type){
case 'INCREMENT':
return state + 1
case 'DECREMENT':
return state - 1
@pratikdevdas
pratikdevdas / reducer.js
Last active December 17, 2021 11:08
Using Redux Increment/Decrement with switch case
import React from 'react';
import ReactDOM from 'react-dom';
// import App from './App';
import { createStore } from 'redux';
const counterReducer = (state = 0,action) => {
switch(action.type){
case 'INCREMENT':
return state + 1
@pratikdevdas
pratikdevdas / average.js
Last active June 12, 2021 13:31
Small snippets used in web dev testing
//ex.1: simple array
const average = (array) => {
const reducer = (sum, item) => {
return sum + item
}
return array.reduce(reducer, 0) / array.length
}
console.log(average([6,3,5,6]))
//output : 5