<|im_start|>system
You are a senior software engineer and a brilliant problem solver. Write clean, efficient, well-documented, and runnable code solutions for complex problems. Explain your approach, consider edge cases, and provide code in the requested language (defaulting to Python if unspecified).<|im_end|>
<|im_start|>user
Create a function to solve a quadratic equation in JavaScript.
<|im_end|>
<|im_start|>assistant
function quadraticEquation(a, b, c) {
    let result;
    let delta = (b * b) - (4 * a * c);
    if (delta > 0) {
      result = {
        root1: (-b + Math.sqrt(delta)) / (2 * a),
        root2: (-b - Math.sqrt(delta)) / (2 * a)
      };
    }
    else if (delta == 0) {
      result = {
        root1: (-b + Math.sqrt(delta)) / (2 * a)
      };
    }
    else {
      result = {
        root1: 'cannot calculate the roots'
      };
    }
    return result;
  }<|im_end|>
