Question
IT Review JAVASCRIPT (Can someone please help me answer the below questions. It would be nice if you add comments explaining what you are doing?
IT Review JAVASCRIPT
(Can someone please help me answer the below questions. It would be nice if you add comments explaining what you are doing? If unable to add comments the answer would be fantastic. Thank you.
For each of the questions below, indicate what will print.
- var x = 3; var y = 2;
if (x / y >= 2)
{
document.write(x + y);
}
else
{
document.write(x * y);
}
- var x = 5; var y = 4;
if (y - x >= 0)
{
document.write(x + y);
}
else if (x % y == 0)
{
document.write(y - x);
}
else
{
document.write(x * y);
}
- var i = 0;
while (i <= 5)
{
document.write(i + ' ');
i++;
}
- function mystery(a, b)
{
var answer = b a / 2;
return answer;
}
var x = 4;
var y = 2;
document.write(mystery(x, y));
- function mystery(a)
{
for(var i = a; i > 0; i++)
{
document.write(i);
}
}
mystery(4);
- var word = Hello;
for (var i = 0; i <= 4; i++)
{
document.write(word.charAt[i]);
}
- var nums = [4, 2, 1, 3];
if (nums [2] == 2)
{
if (nums.length >= 3)
{
document.write("a");
}
else
{
document.write("b");
}
}
else
{
if (nums.length <= 3)
{
document.write("c");
}
}
- var color = blue;
var shape = circle;
var result = ;
if (shape == Circle)
{
if (shape.length > 4)
{
result += S;
}
else
{
result += H;
}
}
else if (color.endsWith(e))
{
if (color.length <= 4)
{
result += A;
}
if (shape.length != 5)
{
result += P;
}
}
else
{
result += E;
}
document.write(result);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started