Hey Guys in the below code every time the if statement is executed no matter what the condition is.
function addRow(tableID) {
var table = document.
This is why I love yoda conditionals. You're assigning a value (=
) rather than evaluating it ==
.
EDIT As suggested, I may point out that the order of checks in this particular statement is wrong. The check whether an element #select_degree
exists should naturally occur before attempting to modify its properties.
However, given the element exists, the condition would still always evaluate true since the return value of the assignment (=
) is used as an argument. As advocator for yoda conditionals, might I point out their advantage: for the following statement a syntax error would have been raised:
if ('hidden' = element.style.visibility)
{
// ...
}