Skip to content

Instantly share code, notes, and snippets.

@Tribhuwan-Joshi
Tribhuwan-Joshi / Main.js
Created December 15, 2022 03:55
Memory Card
import { useEffect, useState } from "react";
function getFormatData(data) {
const res = [];
for (let i of data) {
const obj = {};
obj.url = i.url;
obj.name = i.breeds[0].name;
res.push(obj);
}
import React from "react";
export default function Meme() {
const [meme, setMeme] = React.useState({
topText: "",
bottomText: "",
randomImage: "http://i.imgflip.com/1bij.jpg",
});
const [allMemes, setAllMemes] = React.useState([]);
@Tribhuwan-Joshi
Tribhuwan-Joshi / App.js
Created November 19, 2022 12:00
React form
import React from "react"
export default function App() {
const [formData , setFormData] = React.useState({
email:"",
password:"",
confirmation:"",
newsletter:false
@Tribhuwan-Joshi
Tribhuwan-Joshi / test.js
Created November 12, 2022 09:31
call vs apply vs bind
/* With the call() method, you can write a method that can be used on different objects. */
const person = {
fullName: function() {
return this.firstName + " " + this.lastName;
}
}
const person1 = {
firstName:"John",
lastName: "Doe"
}
{
"env": {
"browser": true,
"commonjs": true,
"es2021": true
},
"extends": ["airbnb-base", "prettier"],
"overrides": [{
"files": ["**/*.test.js"],
"env": {
class Node{
constructor(value) {
this.value = value;
this.left = null;
this.right = null;
}
}
class BST{
@Tribhuwan-Joshi
Tribhuwan-Joshi / index.js
Created September 22, 2022 01:27
Weather App
const app = (() => {
function giveData(day) {
const res = {};
res.weather = day.weather[0].main;
res.temp = day.main.temp;
res.feelslike = day.main.feels_like;
res.windSpeed = day.wind.speed;
res.humidity = day.main.humidity;
res.pop = `${day.pop * 100}%`;
res.icon = day.weather[0].icon;
@Tribhuwan-Joshi
Tribhuwan-Joshi / webpack.config.js
Created September 21, 2022 07:20
webpack config with babel , tailwind and eslint
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
module.exports = {
experiments: {
topLevelAwait: true,
},
mode: "development",
entry: "./src/index.js",
output: {
@Tribhuwan-Joshi
Tribhuwan-Joshi / index.html
Created September 16, 2022 11:26
API to get gifs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<img src="#" alt="gif">
@Tribhuwan-Joshi
Tribhuwan-Joshi / domManipulation.js
Created August 20, 2022 11:42
files for TODO app
const format = require('date-fns/format');
const containerAddTask = document.querySelector('.container-addTask');
function renderTask(taskName, taskNote, priorityValue, dueDate) {
const newTask = document.createElement('div');
let priorityColor;
if (priorityValue === 'high') {
priorityColor = 'red';
}
else if (priorityValue === 'medium') {