Skip to content

Instantly share code, notes, and snippets.

View Megajjks's full-sized avatar
🎯
Focusing

Jayro_Salazar Megajjks

🎯
Focusing
View GitHub Profile
{
"terminal.integrated.shell.linux": "/bin/zsh",
"terminal.integrated.fontFamily": "FiraMono Nerd Font",
"terminal.integrated.fontSize": 12,
"terminal.integrated.fontWeight": "normal",
"workbench.settings.editor": "json",
"editor.fontFamily": "Fira Code",
"editor.fontSize": 20,
"editor.fontWeight": "500",
"editor.fontLigatures": true,
{
"terminal.integrated.shell.linux": "/bin/zsh",
"terminal.integrated.fontFamily": "FiraMono Nerd Font",
"terminal.integrated.fontSize": 12,
"terminal.integrated.fontWeight": "normal",
"workbench.settings.editor": "json",
"editor.fontFamily": "Fira Code",
"editor.fontSize": 20,
"editor.fontWeight": "500",
"editor.fontLigatures": true,
function countSmileys(arr) {
let smiles = 0;
let eyes = [";", ":"];
let noses = ["-", "~"];
let mouth = [")", "D"];
for (let i = 0; i < arr.length; i++){
if (arr[i].length == 3){
if (((eyes.indexOf(arr[i][0]) != -1)) && (noses.indexOf(arr[i][1]) != -1) && (mouth.indexOf(arr[i][2]) != -1)){
smiles++;
}
@Megajjks
Megajjks / question1.js
Created October 18, 2020 21:52
Ways to itered a data in javascript Interview questions
// 1. Demonstrate all the different ways to iterate the below array
const myArray = [1, 2, 3, 4, 5, 6];
// 1 method
for (let index = 0; index < myArray.length; index++) {
console.log(myArray[index])
}
// 2 method
@Megajjks
Megajjks / Component.js
Last active August 26, 2020 19:13
boilerplate of Create component with useReduce
import React, { useReducer } from "react" //implement the useReducer
import { actions } from "./actions" //you can change the path depending where is it located the file actions
import { initialState } from "./constants" //you can change the path depending where is it located the file actions
import { reducer } from "./reducer" //you can change the path depending where is it located the file actions
export const Component = () =>{
//implement the reducer
const [state, dispatch] = useReducer(reducer,initialState)
//reducer refers to the file and the changes that will be executed according to the actions
@Megajjks
Megajjks / Helpers and Filters in JS.js
Last active August 22, 2020 00:21
Helpers and Filters in JS.js
//function that filters a commitment by one or more types of status
//filterWithStatus({...},["query1"...])
export const filterWithStatus = (data, query) => {
const filteredData = data.filter((item) => {
for (let key in query) {
if (item.status === undefined) {
return false;
} else if (query[key].includes(item.status)) {
@Megajjks
Megajjks / peteciones.json
Last active August 1, 2020 07:36
peteciones para el fakeApi
/* Commitments */
[
{
"id": "1",
"createdAt": "2020-07-31T07:33:06.320Z",
"firstName": "Xander",
"lastName": "Satterfield",
"organization": "Agroindustria Honey Kaab",
"sector": "sector_publico",