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=1695458612; bh=5kq7f8WzuwmduDnVaLr3sHP5hnRTNEIyBRdor6hlRio=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=TGg17PX+fkitLN5fDS9+mYZu5fX2u3clzPjFQ0qfgaBLy1wM+dIaXKpWzuVhdXGm9 eXoAiLum7ch6A/4fHCY9tMM4xXjn5Hg0XK1q2ZY2XsrdaRdIXzkmBq+Mtb3CcWENdr 2SpWmI4opzh3h73/6zDZCy2jQ3L8GS0BTShk+o/HP6AFlwgb/dsMoyAjxgz2MJ2d2P nB4iiczJJAUaquN+al2KwyQab7gdDCrCC/XFncSrBlAfDKpRJRlKhd27nBhnCarMLJ E2pb6j/iIJnBQ5Byk5PX92fvqVi4Wha8G3nQT0a4FAh8GwLbkNvBshe3tvKYI6ZGG9 YypKLuM9624eA== Received: from [192.168.1.4] (unknown [175.158.50.129]) by gnuweeb.org (Postfix) with ESMTPSA id F2FA424B6BE; Sat, 23 Sep 2023 15:43:30 +0700 (WIB) Message-ID: Date: Sat, 23 Sep 2023 15:43:27 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH v1 11/11] feat(page): implement chat bubble message rendering Content-Language: en-US To: Ammar Faizi 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> <09f19fe4-9d90-c032-c5ce-4bc92ae20f4c@gnuweeb.org> From: Muhammad Rizki In-Reply-To: <09f19fe4-9d90-c032-c5ce-4bc92ae20f4c@gnuweeb.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: On 23/09/2023 10.15, Ammar Faizi wrote: > 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; > ``` Yes, it doesn't need to complicate the code with `&&`. > @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] >> +        ]; >> +      } > It will be fixed in the next series. Thanks!