Skip to content

Instantly share code, notes, and snippets.

const Direction = { North: 0, South: 1, East: 2, West: 3 };
class Room {
constructor(roomNo) {
this.no = roomNo;
this.sides = new Array(4);
}
setSide(direction, mapSite) {
this.sides[direction] = mapSite;
const Direction = { North: 0, South: 1, East: 2, West: 3 };
class Room {
constructor(roomNo) {
this.no = roomNo;
this.sides = new Array(4);
}
setSide(direction, mapSite) {
this.sides[direction] = mapSite;
@import(base.css) layer(base);
@layer base {
.text {
color: green;
}
}
@ms314006
ms314006 / base.css
Last active October 16, 2022 09:22
/* 定義一個名字叫做 base 的 cascade layer */
@layer base {
}
class Box {
constructor() {
this.price = 50;
this.products = [];
}
get totalPrice() {
const productsTotalPrice = this.products.reduce(
(totalPrice, product) => totalPrice + product.totalPrice, 0
);
class Box {
// 略
get totalPrice() {
const productsTotalPrice = this.products.reduce(
(totalPrice, product) => totalPrice + product.totalPrice, 0
);
return productsTotalPrice + this.price;
}
class Product {
constructor(name, price) {
this.name = name;
this.price = price;
}
get totalPrice() {
return this.price;
}
}
class Box {
// 略
get totalPrice() {
const productsTotalPrice = this.products.reduce(
(totalPrice, product) => {
if (product.constructor === Bag) {
return totalPrice + product.totalPrice;
}
return totalPrice + product.price
@ms314006
ms314006 / package.js
Last active September 25, 2022 02:12
class Box {
constructor() {
this.price = 50;
this.products = [];
}
get totalPrice() {
const productsTotalPrice = this.products.reduce(
(totalPrice, product) => totalPrice + product.price, 0
);
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-await-in-loop */
/* eslint-disable guard-for-in */
import * as yup from 'yup';
import { useState } from 'react';
const useForm = (validationConfig, form) => {
const initialValidateResult = {};
Object.keys(validationConfig).forEach((validationKey) => {
initialValidateResult[validationKey] = {