Workshop › Wordle-style Word Guess › Step 13 of 26
score(guess, word) gives one mark per letter. First the easy part: a letter in the right place is 'green', and every
other letter stays 'gray' for now.
```js
function score(guess, word) {
const marks = Array(5).fill('gray')
for (let i = 0; i < 5; i++) {
if (guess[i] === word[i]) marks[i] = 'green'
}
return marks
}
```Array(5).fill('gray') makes ['gray', 'gray', 'gray', 'gray', 'gray'].'green'.return marks gives the list back.Under the reset function, leave an empty line and write score. Press Run.
Skills: Arrays and objects
← A secret word Right letter, wrong place →