Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript I couldn't solve the javascript questions. Can you help me?

Belge24

Coder
Question 1 : How to rewrite the method foo()

const someText = 'some string';
function foo(){
if(someText.indexOf('string')!=-1){
return true
}
return false
}

a - someText.includes('string')
b - someText.endsWith('string')
c - someText.repeat(5)

Question 2: In ES6+(and further), what are properties intializers?
  • A. Private class properties
  • B. Setters that can be called from an extended class
  • c. A way to declare class properties without using a constructor() method
Question 3: What is rest parameters ?
Question 4: What does the "display: flex" property?
  • A. Displays an element as either block or inline, depending on context.
  • B. The element is displayed as an inline-level table
  • C. Displays an element as an block-level flex container.
  • D. Displays an element as either block or inline, depending on context
Question 5: How can you rewrite this?
const bar = true;
let foo = 'ok';
if(this.bar ===false){
foo='not ok';
}

Question 6: What does the "box-sizing: border-box" property?

A. The proprety don't exist.
B. The width and height properties (and min/max properties) includes only the margin.
C. The width and height properties (and min/max properties) includes content, padding and border, but not the margin.
D. The width and height properties (and min/max properties) includes only the content. Border, padding, or margin are not included.

Question 7: What is correct syntax for string interpolation?

A. none of these answer
B. ${customer.name)
C. #(customer.name)
D. @(customer.name}

Question 8: How define a 2D rotation of 10 degrees?
A. transition : rotate(10deg)
B. transition : scale(10d)
C. transform : rotate(10deg)
D. transform : rotate(10d)

Question 9: What does the === Identity operator?
A. Returns true if the operands are strictly equal with type conversion
B. Returns true if the operands are strictly equal with no type conversion

Question 9: When to use the funtion map in javascript ?
A. Change every item in an array
B. none of these answer
C. Split an array
D. Filter elements

Question 10: What is the correct syntax for referring to an external script called "myFile.js"

Question 11: What does the <noscript> tag do ?
A. Describes ceetain low-budget movies.
B. Enclose text to be displayed by non-Javascript browsers.
C. none of these answer
D. Prevents scripts on the page from executing.

Question 12: What display this code?
A. est
B. test
C. non of these answer
D. es

Question 13: Which of the following type of variable is visible everywhere in your Javascript code
A. Local variable
B. none of these answer
C. Global variable

Thank you very much for your answers :blush:
 
1 - a - someText.includes('string')
3 - Rest parameters are used to create functions that accept any number of arguments.
4 . Displays an element as either block or inline, depending on context
5.
const bar = true;
let foo = 'ok';
if(this.bar !=true){
foo='not ok';
}
6 . The width and height properties (and min/max properties) includes only the content. Border, padding, or margin are not included.
8 - transition : rotate(10deg)
9 - Returns true if the operands are strictly equal with type conversion
10 -
<script src="index.js"></script>
<script src="my_file.js"></script>
</body>
11 Prevents scripts on the page from executing.
12 - C. non of these answer
13 - Global variable
 
1 - a - someText.includes('string')
3 - Rest parameters are used to create functions that accept any number of arguments.
4 . Displays an element as either block or inline, depending on context
5.
const bar = true;
let foo = 'ok';
if(this.bar !=true){
foo='not ok';
}
6 . The width and height properties (and min/max properties) includes only the content. Border, padding, or margin are not included.
8 - transition : rotate(10deg)
9 - Returns true if the operands are strictly equal with type conversion
10 -
<script src="index.js"></script>
<script src="my_file.js"></script>
</body>
11 Prevents scripts on the page from executing.
12 - C. non of these answer
13 - Global variable
Thank you very much my friend cno :blush:
 
What's the unit test behavior on command "mocha test.js" (Mocha/Chai/Sinon ES6)?

test.js:

const should = require('chai').should();

const sinon = require('sinon');

a=()=>{

return false;

}

b=()=>{

return true;

}

it('should work', ()=>{

sinon.spy(global, 'a');

sinon.stub(global, 'b').returns(false);

a().should.equal(false);

b().should.not.equal(true);

a();

a.callCount.should.equal(2);

b.callCount.should.equal(1);

});



  • A. 1) should work

1 failing


Because a() returns undefined not false



  • B. should work


1 passing



  • C. 1) should work


1 failing

Because "a" has not the expected callCount



  • D. 1) should work


1 failing

Because b() does not return the expected value
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom