Code QuizAdvanced

StringBuilder Inside the Loop

Spot why this StringBuilder loop returns only the last item instead of all of them.

Codejava
public String joinNames(List<String> names) {
    String result = "";
    for (String name : names) {
        StringBuilder sb = new StringBuilder();
        sb.append(name).append(", ");
        result = sb.toString();
    }
    return result;
}

What is the bug in this code?