I've been stuck for quite some time with the following code. It works but the variable loses the value that was set during the iterations.
I have the following code
checkIfLetterInsideWord(){
for (( i=1; i <= $word_length; i++))
do
if [[ "$1:$i-1:1}" = ${letter} ]]; then
exists=1
answer_guess=$(echo $answer_guess | sed "s/-/${letter}/{i}" }
fi
done
}
I want to preserve the value of the variable answer_guess. I understand that it loses the value because of the usage of a pipeline inside the loop but I don't know to approach this problem.
