-1

我试图在运行函数后将字符串存储到变量中。当它运行时,它返回未定义。在底部我尝试添加return marginDirection;,但它仍然返回未定义。我不确定我哪里出错了。我在这一点上被卡住了。任何帮助,将不胜感激!谢谢

var marginDirection = getMarginDirection();

            function getMarginDirection() {
                if (floatDirection == 'right') { 
                    marginDirection == 'left'; 
                    } 
                else if (floatDirection == 'left') { 
                    marginDirection == 'right'; 
                    } 
                else { 
                    marginDirection == ''; 
                    }
                };
4

1 回答 1

2
function getMarginDirection()
{
    if (floatDirection == 'right')
        marginDirection = 'left'; 
    else if (floatDirection == 'left')
        marginDirection = 'right'; 
    else
        marginDirection = '';

    return marginDirection;
}

Return=变量并用not赋值==

于 2013-07-27T18:33:15.403 回答