Skip to content

Instantly share code, notes, and snippets.

View edwinaquino's full-sized avatar
💭
Data Center Manager

Edwin Aquino edwinaquino

💭
Data Center Manager
View GitHub Profile
//https://formik.org/docs/overview
/**
Source: https://formik.org/docs/tutorial
Search for "message if the field is invalid and it has been touched" to find the example variabled used in this component. for example: MyTextInput
*
*/
import { useField } from 'formik';
export const MyTexArea = ({ label, ...props }) => {
// useField() returns [formik.getFieldProps(), formik.getFieldMeta()]
// which we can spread on <input>. We can use field meta to show an error
@edwinaquino
edwinaquino / linked-list-count-nodes-recursive.js
Last active December 25, 2021 07:30
Recursive- Count number of nodes in a Linked List by implementing a recursive algorithm.
// Recursive version
// Similar to https://gist.github.com/edwinaquino/2c32637d6a15348667c2df673cc196b5
// Create a node
class Node {
constructor(val) {
this.data = val;
this.next = null;
}
}
@edwinaquino
edwinaquino / linked-list-count-nodes.js
Last active December 25, 2021 07:40
Count number of nodes in a Linked List by implementing an iterative algorithm.
// Create a node
class Node {
constructor(val) {
this.data = val;
this.next = null;
}
}
let head;
@edwinaquino
edwinaquino / binary-search.js
Created December 15, 2021 10:31
The purpose of this simple script is to find the index in an array using the Binary Search Method.
// Edwin Aquino
// The purpose of this simple script is to find the index in an array using the Binary Search Method.
// Function to search for a match in all the elements in an array
function binarySearch(arr, e) {
// declare and assign the first element index
let head = 0;
// declare and assign the last element index
let tail = arr.length - 1;
// declare and assign the middle point of the array
let mid = Math.floor((head + tail) / 2);
@edwinaquino
edwinaquino / linear-search.js
Created December 15, 2021 10:09
Linear search in Javascript
// December 15, 2021 . Edwin Aquino
// The purpose of this simple script is to find the index in an array using the Linear Search Method.
// Function to search for a match in all the elements in an array
function linearSearch(arr, e) {
// Use a loop to irritate through the loop
for (let i = 0; i < arr.length; i++) {
// Identify the match and return the index value
if(arr[i] ===e) return i;
}