WorksheetsWeb6
Total questions: 44
Worksheet time: 22mins
Result of the script if a=6, b=8:
script
st=prompt(‘a=’);
a=parseInt(st);
st=prompt(‘b=’);
b=parseInt(st);
s=a*b;
st=’s=’+s;
alert(st);
/script
Result of the script if n=15:
script
st=prompt(‘n=’);
n=parseInt(st);
k=0;
for(i=1; i<=n; i++)
if (n%i==0) k++;
alert(k);
/script
Result of the script if s=moloko:
script
st=prompt(‘ ’); L=s.length;
k=0;
for(i=0; i<L; i++)
{
c=s.charAt(i);
if (c==’o’) k++;
}
alert(k);
/script
Result of the script:
script
var num=2;
var power=10;
var result=1;
var subpower=1
while (subpower<=power){result*=num;subpower++};
document.write(result)
/script
Result of the script:
script
var i=1;
for (var i = 1; i <= 50; i++) {
document.write(i + '<br>');
}
/script
Result of the script:
script
var i = 1;
while (i <= 50)
{
document.write(i + '<br>'); i++;
}
/script
Result of the script:
script
var arr = [1, 2, 4, -1, -3, 8, 7, 0, -5, 18, 12];
for (var i = 0; i < arr.length; i++)
{
if(arr[i] > 0 && arr[i] < 10)
{
document.write(arr[i]);
}
}
/script
Result of the script:
script
var arr = [1, 2, 3, 4, 5];
var sum = 0;
for (var i = 0; i < arr.length; i++)
{
sum += arr[i];
}
alert(sum);
/script
Result of the script:
script
var arr = [1, 2, 3, 4, 5];
var sum = 0;
for (var i = 0; i < arr.length; i++)
{
sum += arr[i] * arr[i];
}
alert(sum);
/script
Result of the script:
script
var arr = [1, 2, 3, 7, 6, 9];
var sum = 0;
for (var i = 0; i < arr.length; i++)
{
sum += arr[i];
}
var result = sum / arr.length;
alert(result);
/script
Result of the script:
script
for (var i = 2; i < 100; i += 2)
{
document.write(i + '<br>');
}
/script
Result of the script:
script
var a = 10;
var b = 3;
alert(a %b);
/script
Result of the script:
script
var a = 10;
var b = 3;
alert(a / b);
/script
Result of the script:
script
var arr = ['Hello, ', 'world', '!'];
alert(arr[0] + arr[1] + arr[2]);
/script
Result of the script:
script
var arr = ['Hello, ', 'world', '!'];
arr[0] = 'Bye, ';
alert(arr);
/script
Result of the script:
script
var str = 'abcde';
alert(str[4]);
/script
Result of the script:
script
var num = 1;
num = num + 12;
num = num - 14;
num = num * 5;
num = num + 1;
num = num - 1;
alert(num);
/script
Result of the script:
script
var num = 47;
num = num + 7;
num = num - 18;
num = num * 10;
num = num / 15;
alert(num);
/script
Result of the script:
<button onclick="alert('Hello!')">Click me</button>
Result of the script:
script
var num = 10;
if (num == 10)
{
alert('True');
}
Else
{
alert('False');
}
/script
Result of the script:
script
var result = 1;
var arr = [2, 3, 4, 5];
for (var i = 0; i < arr.length; i++)
{
result = result * arr[i];
}
alert(result);
/script
Result of the script:
script
var arr = { 'ru':['голубой', 'красный', 'зеленый'],
'en':['blue', 'red', 'green'], };
alert(arr['ru'][0]);
/script
Result of the script:
script
var arr = { 'ru':['голубой', 'красный', 'зеленый'],
'en':['blue', 'red', 'green'], };
alert(arr['en'][1]);
/script
Result of the script:
script
var str = 'aaa bbb ccc';
alert(str.substr(4, 3));
/script
Result of the script:
script
var str = 'aaa bbb ccc';
alert(str.substring(8, 11));
/script
Result of the script:
script
var a = ['a', 'b', 'c'];
var b = [1, 2, 3];
var c = a.concat(b);
alert(c);
/script
Result of the script:
script
var a = ['a', 'b', 'c'];
var b = [1, 2, 3];
var c = b.concat(a);
alert(c);
/script
Result of the script:
script
var str = 'aaa@bbb@ccc';
alert(str.replace('@', '!'));
/script
Result of the script:
script
alert(Math.max(1, 5, 10, 34, 100));
/script
Result of the script:
script
alert((Math.floor(2.9999));
/script
Result of the script:
script
alert((Math.abs(-3));
/script
Result of the script:
script
let str = 'abcde';
console.log(str.length);
/script
Result of the script:
script
let str = 'Я учу учу Javascript';
console.log(str.indexOf('учу'));
/script
Result of the script:
script
let str = 'Я учу учу Javascript';
console.log(str.indexOf('учу', 5));
/script
Result of the script:
script
for (var i = 100; i > 0; i--)
{
document.write(i + '<br>');
}
/script
Result of the script:
script
var i = 2;
while( i < 9 ){
document.write( i++ );
}
/script
