Get random item from Array

    0

    1

    monizb

    Gets a random variable from an Array with a random generated index value

    const items = ["A", "B", "C","D"]
    const randomIndex = Math.floor(Math.random()*items.length)
    items[randomIndex]
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.