#help with functions/if statements

17 messages · Page 1 of 1 (latest)

near plume

help with functions/if statements

wise forum

Did you delete it or already solved ?

near plume

i didnt delete it?

they told me it was the wrong channel so i made a poist here

wise forum

It's dead

That's what I was referring to

near plume

@wise forum


let puzzleWords = ['coding' || 'keyboard' ]
function randomizeWords(words) {
  let randomizeWord = [];
  for (let i = 0; i < words.length; i++) {
    let word = puzzleWords[i];
    let scrambledWord = "";
    while (word.length > 0) {
      let index = Math.floor(Math.random() * word.length);
      scrambledWord += word[index];
      word = word.substring(0, index) + word.substring(index + 1);
    }
    randomizeWord.push(scrambledWord);
  }
  return randomizeWord;
}


let randomizedWord = randomizeWords(puzzleWords)


const embed = new EmbedBuilder()
.setDescription(`${randomizedWord}`)

interaction.reply({ embeds: [embed] })
wise forum

Any errors ?

Lemme read the code rq

near plume

no errors im just asking how to get the correctly spelled word to show like in my console

wise forum

not the or operator ||

Other than that I have to apologize because I can't process that rn ohno
Maybe someone else is better suited than me to actually say if it's working or not

near plume

i want a single word scrambled at a time, not both. thats why its ||