what will be the output?
var msg = 'codingdojo';
for(var x =-2; x
{
if(msg.length == 5)
{
for(var i =2; i<5; i++)
{
console.log(i)
}
}
else
{
for(var i = msg.length; i>(msg.length -2); i++)
{
console.log(i);
}
}
}
There are some syntax error so code will not run.
first for loop must be like
for (statement
1; statement 2; statement 3) {
// code block to be
executed
}
for(var x =-2; x here is no closing bracket, conditional statement.
secondly console.log(i) here semicolon(;) is missing.
tThere
what will be the output? var msg = 'codingdojo'; for(var x =-2; x { if(msg.length ==...
1. var s = "A red boat"; var a = s.split(" "); what is the value of a? var b = [9, 3, 2, 1, 3, 7]; var c = b.slice(2, 5); What is the value of c? var d = c.concat(a); alert(d.join("**")); [ 'A', 'red' , 'boat'] [ 2 , 1, 3] 2**1**3**A**red**boat [ 'A', 'red' , 'boat'] [ 1 , 3, 7] 8**A**red**boat [ 'A', 'red' , 'boat'] [ 3 , 2, 1] A**red**boat [ 'A', 'red' ,...
how is this solves? function looping(x,y){ for(var i=0; i<x; i++){ for(var j=0; j<x; j++){ console.log(i*j); } } } z = looping(3,3); console.log(z);
1. What condition makes the loop output the even numbers 2 through 20? var c = 2; while (_____) { console.log(c); c += 2; } a). c >= 20 b). c <= 20 c). c < 20 2. lowerCaseLetters = "abc"; upperCaseLetters = "ABC"; if (lowerCaseLetters > upperCaseLetters) { length++; } a). true b). false 3. score = 2; if (score === "2") { score = 10; } a).true b).false 4. Indicate if the statements contain...
c++ In the following segment of the code, what will be the output if opening of the file is not successful? ifstream infile; try{ infile.open("test.txt"); if(!infile) throw -1; else cout << "successful" << endl; } catch(const char* msg) { cout << msg << " unsuccessful" << endl; } catch(int i) { cout << i < was returned, unsuccessful" <<endl; #8 WA w
JavaScript Upon invoking/calling the Bill function, what parameter value do we need to pass to this function, in order to console.log("Got Ya!)" Explain what happen to the values for it to get to the console.log var bill = function(amount){ if(amount > 10 && amount <100){ return amount + tax(amount, 1); } else if(amount >= 100){ return amount + tax(amount, 2); } else { return amount; } } var tax = function(price, bracket){ if(bracket === 1){ return price * 0.1; }...
What would the result be if you ran the following code: function makeAdder(x) { return function(y) { return x + y; }; } var add8 = makeAdder(8); var add12 = makeAdder(12); console.log(add8(4)); console.log(add12(5));
Which of the following replacement code fragments will fix the code below? console.log(square); console.log(square(5)); var square = function(n) { return n * n; } A.) alert(square); alert(square(5)); var square = function(n) { return n * n; } B.) console.log(square); console.log(square(5)); var function square = function(n) { return n * n; } C.) console.log(square); console.log(square(5)); function square = function(n) { return n * n; } D.) console.log(square); console.log(square(5)); function square(n) { return n * n; }
For the code below: The output is: ]oftwkre q izze} are*fun! What is the decimal value of a? charm"Software quizzes are fun!"; int i 0 for(i; i < sizeof (msg)/sizeof (msg [0]) i++) msg [i] % 5-0 ? msg [i] + a : msg [i] ; printf("%s\n", msg); charm"Software quizzes are fun!"; int i 0 for(i; i
Prove, Var(ay)= a^2 var(y) Var(y+a)= var(y) Var(x+y)= var(x)+var(y)+2cov(x,y)
2. Desk check this code. var sum = 0; for (var i=1; i <=3; i++) if ((i % 2) 0) { sum += i; else sum-= 1; Desk Check i % 2 sum