Quick actions

cmd+k|ctrl+k

Navigation

Languages

Shuffle String

Snippet info

Language

JavaScript

Visibility

public

Author

arrennbaral

Created

2023-01-08T02:40:31.08673Z

Updated

2023-01-08T02:40:31.08673Z

//String and indices are given. Shuffle the string based on the given string

const shuffle = function(string1,indices){
    let shuffledString=""
    for(let i=0;i<string1.length;i++){
        shuffledString += string1[indices[i]]
        //console.log(shuffledString)
    }
    return shuffledString;
}

console.log(shuffle("TEST",[1,3,0,2]))


INFO