user
Create a function that takes a string of parentheses and determines its validity


assistant
function validateParens(str) {
  let parenthesesCounter = 0;
  for (let i = 0; i < str.length; i++) {
    if (str[i] === '(') {
      parenthesesCounter++;
    } else if (str[i] === ')') {
      parenthesesCounter--;
    }

    if (parenthesesCounter < 0) {
      return false;
    }
  }
  return parenthesesCounter === 0;
}