為什么我的編程練習(xí)代碼在慕課里邊輸不出來判定結(jié)果:通過,而在編程軟件上(DW)上就能輸出來
var num=0;str=0;fun=0;boo=0;win=0;dat=0;nul=0;und=0;
var num1=0;str1=0;fun1=0;boo1=0;win1=0;dat1=0;nul1=0;und1=0;
? ? ? ? ? ? ? ?if (arr1 instanceof Array && arr2 instanceof Array){ ? ?//判斷是不是數(shù)組
? ? ? ? ?if(arr1.length==arr2.length){ ? ? ?//判斷長度是不是相等
? ? ? ?for(var i=0;i<arr1.length;i++){ ? ? ?//for循環(huán)獲取他們每一個數(shù)據(jù)類型的個數(shù) ,并儲存在變量中
if( typeof arr1[i]==="number"){num++}
if( typeof arr1[i]==="string"){str++}
if( typeof arr1[i]==="boolean"){boo++}
if( typeof arr1[i]==="function"){fun++}
if( typeof arr1[i]==="undefined"){und++}
if( Object.prototype.toString.call(arr1[i])==="[object Date]"){dat++}
if( Object.prototype.toString.call(arr1[i])==="[object Window]"){win++}
if( Object.prototype.toString.call(arr1[i])==="[object Null]"){nul++}
? ?if( typeof arr2[i]==="number"){num1++}
if( typeof arr2[i]==="string"){str1++}
if( typeof arr2[i]==="boolean"){boo1++}
if( typeof arr2[i]==="function"){fun1++}
if( typeof arr2[i]==="undefined"){und1++}
if( Object.prototype.toString.call(arr2[i])==="[object Date]"){dat1++}
if( Object.prototype.toString.call(arr2[i])==="[object Window]"){win1++}
if( Object.prototype.toString.call(arr2[i])==="[object Null]"){nul1++}
}
if(num==num1 && str==str1 && fun==fun1 && boo==boo1 && win==win1 && dat==dat1 && nul==nul1 && und==und1){ ? ?//判斷他們每一種數(shù)據(jù)類型的個數(shù)相不相等
return true;
}else{ return false; }
? ?}else{ return false }
? ? ? ? ? ? ? ?}else{ return false }?
2015-04-02
仔細(xì)看題,題目要求了要以特定的函數(shù)名作為API,而在校驗編程題目是否正確時會調(diào)用指定的API。