什么';javascript代码有什么问题

什么';javascript代码有什么问题,javascript,Javascript,当您在控制台中运行此代码时,它工作正常,但不是这样工作的- 这适用于控制台- function solveEquation() { // format ax+by=c var eq1 = "3x+5y=4", // equation 1 eq2 = "5x+6y=2", // equation 2 // separate ax, by & c eq1Parts = eq1.split(/[\+\-\=]/),

当您在控制台中运行此代码时,它工作正常,但不是这样工作的-

这适用于控制台-

function solveEquation() {
    // format ax+by=c
    var eq1 = "3x+5y=4", // equation 1
        eq2 = "5x+6y=2", // equation 2

        // separate ax, by & c
        eq1Parts = eq1.split(/[\+\-\=]/),
        eq2Parts = eq2.split(/[\+\-\=]/),

        // get the value of a, b & c
        a1 = parseInt(eq1Parts[0]),
        b1 = parseInt(eq1Parts[1]),
        c1 = parseInt(eq1Parts[2]),
        a2 = parseInt(eq2Parts[0]),
        b2 = parseInt(eq2Parts[1]),
        c2 = parseInt(eq2Parts[2]),

        // substitution and elimination
        // https://www.khanacademy.org/math/algebra/systems-of-eq-and-ineq/fast-systems-of-equations/e/systems_of_equations

        B1 = b1 * a2,
        C1 = c1 * a2,
        B2 = b2 * a1,
        C2 = c2 * a1,
        // A1 and A2 cancels out, no need to specify them

        // unknowns
        y = (C1 - C2) / (B1 - B2),
        x = (c1 - b1 * y) / a1; // putting the value of y in equation 1

    ansContainer.textContent = "x = " + x + ", y = " + y;
}

我知道这是一个错误代码,这是非常早期的阶段,我卡住了。

你会得到一个除以零的结果

var eq1Container = document.getElementById("input-eq1"),
    eq2Container = document.getElementById("input-eq1"), <-- references same input
var eq1Container=document.getElementById(“input-eq1”),

eq2Container=document.getElementById(“input-eq1”),ansContainer.textContent未定义
ansContainer=document.getElementById(“ans container”)
控制台告诉您一切,查看它是否有错误消息。定义预期输出、实际输出和边界条件(哪些值是应该产生输出的函数范围之外的变量)。指向小提琴很好,但它不够。控制台中没有错误…哦,妈的…哈哈哈,我不敢相信。这是一个愚蠢的错误…我已经吸了几个小时了,但找不到。谢谢。