なぜ red 以外の他の文字を入れても表示されないのですか?

r 以外のキーが入力されると if 文の条件が false となり、何も起こらないためです。
2021年9月8日
ユーザー
    const word = 'red';
    let loc = 0;//位置

    const target = document.getElementById('target');
    target.textContent = word;

    document.addEventListener('keydown',e => {
        if(e.key === word[loc]){
            loc++; 

            target.textContent = '_'.repeat(loc) + word.substring(loc);
        }
    })

なぜ red 以外の他の文字を入れても表示されないのですか?
また、このソースコードのどのあたりで表題の件を表しているのでしょうか?

word で red と定義して target.textContent = word; としただけですと、 red 以外のタイピングを許さないように見えない感じがするのですが...。

この回答を見るにはプレミアムサービスへの登録が必要です

プレミアムサービスとは?