function run(num)
{
var xi=new Array("Fizz","Buzz","Whizz");
var arr=new Array(3,5,7);
var rsulte="";
var flag=0;
for(var i=0;i<3;i++)
{
if(num%arr[i]==0)
{
rsulte +=xi[i];
flag=1;
}
}
if(flag==0)
return num;
else
return rsulte;
}
var test1 = function() {let result = run(2);
if(result == 2) { document.write('The test 1 failed' +'2'); }
else {
document.write('The test 1 result is : '+ result+''); }}
test1()
var test2 = function() {let result = run(3);
if(result ==3) {
document.write('The test 2 failed'+'3'); }
else{ document.write('The test 2 result is : '+ result+'') ; }}
test2()
var test3 = function() {let result = run(5);
if(result ==5) { document.write('The test 3 failed'+'5'); }
else{ document.write('The test 3 result is : '+ result+''); }}
test3()
var test4 = function() {let result = run(7);
if(result ==7) { document.write('The test 4 failed'+'7'); }
else{ document.write('The test 4 result is : '+ result+''); }}
test4()
var test5 = function() {let result = run(15);
if(result ==15) { document.write('The test 5 failed'+'15'); }
else{ document.write('The test 5 result is : '+ result+''); }}
test5()
var test6 = function() {let result = run(21);
if(result ==21) { document.write('The test 6 failed'+'21'); }
else{ document.write('The test 6 result is : '+ result+''); }}
test6()
var test7 = function() {let result = run(35);
if(result ==35) { document.write('The test 7 failed'+'35'); }
else{ document.write('The test 7 result is : '+ result+''); }}
test7()
var test8 = function() {let result = run(105);
if(result !=105) { document.write('The test 8 failed'+'105'); }
else{ document.write('The test 8 result is : '+ result+''); }}
test8()
网友评论