This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reformatPolicyNumbers(paragraph) { | |
const policyNumbers = paragraph.split(" "); | |
policyNumbers.map((word, index) => { | |
const policyNumber = word.split("-"); | |
if (policyNumber.length === 3 && !isNaN(Number(policyNumber.join("")))) { | |
policyNumbers[index] = policyNumber.join("/"); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Problem 1: Move Zeroes | |
function moveZeroToEnd(arr) { | |
const count = {}; | |
const result = []; | |
arr.forEach((element) => { | |
count[element] = (count[element] || 0) + 1; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Calender | |
attr_accessor :start_time, :end_time | |
def initialize(start_time:, end_time:) | |
@start_time = start_time | |
@end_time = end_time | |
end | |
end | |
def is_overlapping?(c1, c2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\Http; | |
class MainContoller extends Controller | |
{ | |
public function login(Request $request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const str = "cats AND*Dogs-are Awesome"; | |
// const str = 'a b c d-e-f%g' | |
const splitted_word = str.split(/\W+/); | |
const result = | |
splitted_word[0].toLocaleLowerCase() + | |
splitted_word | |
.slice(1) | |
.slice(-splitted_word.length) | |
.map((s) => s.charAt(0).toUpperCase() + s.slice(1).toLocaleLowerCase()) | |
.join(""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clean_json(hash) | |
invalid_values = ["N/A", "-", ""] | |
hash.each do |key, value| | |
if value.is_a?(Hash) | |
clean_json(value) | |
if value.values.any? { |v| invalid_values.include?(v) } | |
hash.delete(key) | |
end | |
elsif value.is_a?(Array) | |
value.each do |v| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$mobileMin: 0px; | |
$mobileMax: 425px; | |
$tabletMin: 426px; | |
$tabletMax: 700px; | |
$laptopMin: 941px; | |
$laptopMax: 1440px; | |
$desktopMin: 1441px; | |
$desktopMax: 1920px; | |
$largeDisplayMin: 1921px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function UseRef() { | |
const [name, setName] = useState(''); | |
const renderCount = useRef(1); | |
const prevName = useRef(''); | |
useEffect(() => { | |
renderCount.current = renderCount.current + 1 | |
prevName.current = name; | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useState } from "react"; | |
export default function WindowResize() { | |
const [windowWidth, setWindowWidth] = useState(window.innerWidth); | |
const handleWindowResize = () => setWindowWidth(window.innerWidth) | |
useEffect(() => { | |
window.addEventListener('resize', handleWindowResize); |
NewerOlder