2021-06-29 20:51:43 -04:00

16 lines
529 B
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

let str = "JavaScript";
console.log(scramble(str));
function scramble(val) {
let max = val.length;
let temp = "";
for(let i=0;i<max;i++){
console.log(val.length);
let index = Math.floor(Math.random() * val.length);
temp += val[index]; 
console.log(temp);
val = val.substr(0, index) + val.substr(index + 1);
console.log(val);
}
return val
}