From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1695438960; bh=+g8WxF/2iSOGFgSurX9EmZBsm8FplSGNVF22q9qro5o=; h=Date:To:Cc:References:From:Subject:In-Reply-To; b=in/lP1y9onzwTpNuDw8Y/Po2srD5oKxx9FoRZgY8oKQlscAjwvkZMTcMzhFiLBg+A 2mMFgYACBHOxY6T+so4NTLBYZpjRRa2oG8iarqjeI7N+xxblTviSqg2oAiHlqD5r5s ucjy0Zda64lHPUAusgxx+/LG1Zk4RifTzo8FMmp+UHPNa5gYCZSErdmJ+yhFOXvWZl hNI0jtIyNUoAzUZgoJ9v0qyh5Rq4V+fKj+EFMrzudjqPVZbZaKoA9kryHpcfhcBqC1 AfZVGf42I8yjRVTmHY3tH+VcZJFo3rEr3oHKKbQ4xhcsnRyjaHz9IM7SHeOaTlRb0p 6cuT1TFQaNGyQ== Received: from [10.20.0.2] (unknown [182.253.126.208]) by gnuweeb.org (Postfix) with ESMTPSA id 9998C24B67E; Sat, 23 Sep 2023 10:15:57 +0700 (WIB) Message-ID: <09f19fe4-9d90-c032-c5ce-4bc92ae20f4c@gnuweeb.org> Date: Sat, 23 Sep 2023 10:15:53 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Content-Language: en-US To: Muhammad Rizki Cc: Alviro Iskandar Setiawan , Arthur Lapz , Memet Zx , GNU/Weeb Mailing List References: <20230922205817.107-1-kiizuha@gnuweeb.org> <20230922205817.107-12-kiizuha@gnuweeb.org> From: Ammar Faizi Subject: Re: [PATCH v1 11/11] feat(page): implement chat bubble message rendering In-Reply-To: <20230922205817.107-12-kiizuha@gnuweeb.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: On 2023/09/23 午前3:58, Muhammad Rizki wrote: > + function getFixedRandomColor(name) { > + const textColors = [ > + "text-red-400", "text-yellow-400", > + "text-blue-400", "text-sky-400", > + "text-purple-400", "text-orange-400", > + "text-amber-400", "text-lime-400", > + "text-green-400", "text-emerald-400", > + "text-teal-400", "text-cyan-400", > + "text-indigo-400", "text-violet-400", > + "text-fuchsia-400", "text-pink-400", > + "text-rose-400" > + ]; > + const borderColors = [ > + "border-red-400", "border-yellow-400", > + "border-blue-400", "border-sky-400", > + "border-purple-400", "border-orange-400", > + "border-amber-400", "border-lime-400", > + "border-green-400", "border-emerald-400", > + "border-teal-400", "border-cyan-400", > + "border-indigo-400", "border-violet-400", > + "border-fuchsia-400", "border-pink-400", > + "border-rose-400" > + ]; > + > + const hash = hashCode(name); > + const range = textColors && textColors.length; At a glance, I thought that @range was a boolean. But it's not. What does the "&&" operator do? Can't you just assign it this way? ``` const range = textColors.length; ``` @textColors is always defined. I don't think it needs that stupid "&&" op game either. What's the purpose behind it? > + const indexColor = hash % range; > + > + return [ > + textColors[(hashCode(name)) % range], > + borderColors[(hashCode(name)) % range] > + ]; > + } -- Ammar Faizi