👉 𝗟𝗲𝘁’𝘀 𝗴𝗲𝘁 𝘀𝘁𝗮𝗿𝘁𝗲𝗱 🧑💻
🌶️ 𝗛𝗼𝘄 𝘁𝗼 𝗿𝗲𝗺𝗼𝘃𝗲 𝗳𝗮𝗹𝘀𝘆 𝘃𝗮𝗹𝘂𝗲𝘀 𝗳𝗿𝗼𝗺 𝗮𝗻 𝗮𝗿𝗿𝗮𝘆 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁.
🌶️ 𝗛𝗼𝘄 𝘁𝗼 𝗴𝗲𝘁 𝗮 𝗿𝗮𝗻𝗱𝗼𝗺 𝗲𝗹𝗲𝗺𝗲𝗻𝘁 𝗳𝗿𝗼𝗺 𝗮𝗻 𝗮𝗿𝗿𝗮𝘆 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁.
Sometimes we need to select a value from the array randomly. To create it, we can get a random index number according to the array length.🚀
🌶️ 𝗛𝗼𝘄 𝘁𝗼 𝗦𝗵𝘂𝗳𝗳𝗹𝗲 𝗮𝗻 𝗔𝗿𝗿𝗮𝘆 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁
Shuffling is easy with the sort method. As long as it returns a random number, positive or negative, we can sort it with a random order.🚀
🌶️ 𝗛𝗼𝘄 𝘁𝗼 𝗙𝗶𝗻𝗱 𝘁𝗵𝗲 𝗶𝗻𝘁𝗲𝗿𝘀𝗲𝗰𝘁𝗶𝗼𝗻 𝗼𝗳 𝘁𝘄𝗼 𝗮𝗿𝗿𝗮𝘆𝘀 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁.
We can use a Set() to ensure that values in the array we are checking are not duplicated, and we will use .filter and .includes methods. As a result, we will get the array with values that were presented in both arrays.🚀