# Introduction In this lab, we will explore a practical implementation of a weighted sample function in JavaScript. The function returns a random element from an array, with probabilities assigned to each element based on the provided weights. Through this lab, we will learn how to use Array methods such as reduce() and findIndex() along with Math.random() to generate the desired outcome.
Click the virtual machine below to start practicing