Free Web-Development-Applications Exam Braindumps
WGU Web Development Applications (KVO1) Questions 31–35 (page: 8)

Updated On: 10-Feb-2026

Which code segment correctly defines a function in JavaScript?

  1. Void addNumbers(a, b)
  2. Function addNumbers (a, b)
  3. Void addNumber(int a, int b)
  4. Function addNumber (in a, int b)

Answer(s): B

Explanation:

In JavaScript, functions are defined using the function keyword followed by the name of the function, a set of parentheses (), and a block of code enclosed in curly braces {}.

Function Definition Syntax:

Correct Syntax:

function addNumbers(a, b) {

// function body

}

function: Keyword to define a function.

addNumbers: Name of the function.

(a, b): Parameters for the function.

{ ... }: Function body containing the code to be executed.

Incorrect Options:

A . Void addNumbers(a, b): JavaScript does not use void to define functions.

C . Void addNumber(int a, int b): JavaScript does not use void or type declarations (int).

D . Function addNumber (in a, int b): JavaScript functions do not use type declarations.


Reference:

MDN Web Docs - Functions

W3Schools - JavaScript Functions



Given the following code:



What does the console display as output?

  1. 8
  2. 86
  3. 14

Answer(s): B

Explanation:

Given the code segment:

var a = "8";

var b = "6";

var c = a + b;

console.log(c);

This code concatenates two strings.

var a = "8";: Variable a is assigned the string "8".

var b = "6";: Variable b is assigned the string "6".

var c = a + b;: The + operator concatenates the two strings, resulting in "86".

console.log(c);: Outputs the value of c to the console.

Output:

The console displays "86" because it concatenates the two string values.


Reference:

MDN Web Docs - String

W3Schools - JavaScript String



Which code segment contains a conditional expression?

A)



B)



C)



D)

  1. Option A
  2. Option B
  3. Option C
  4. Option D

Answer(s): D

Explanation:

A conditional expression in JavaScript is an expression that evaluates to a boolean value and controls the execution flow based on its result. The conditional (ternary) operator ? : is used for conditional expressions.

Example Analysis:

Option A:

var result = dataCount;

This is a simple assignment, not a conditional expression.

Option B:

var result = count++ > 10;

This is a comparison but not a complete conditional expression.

Option C:

var result = dataCount++ * 1000 == 3000000;

This is an arithmetic operation followed by a comparison but not a complete conditional expression.

Option D:

javascript

Copy code var result = count >= 10 ? "Done" : getResult();

This is a conditional (ternary) expression. If count is greater than or equal to 10, result will be "Done", otherwise, it will call getResult().


Reference:

MDN Web Docs - Conditional (ternary) operator

W3Schools - JavaScript Conditions



Which History API object is called when a browser window's document history changes?

  1. Window, location
  2. Window, onpopstate
  3. Window, name
  4. Window, open

Answer(s): B

Explanation:

The onpopstate event is triggered in the window object when the active history entry changes, such as when the user navigates to a different page using the back or forward buttons in the browser.

History API and onpopstate:

Event: window.onpopstate

Description: This event is fired when the user navigates to a session history entry, i.e., when moving backwards or forwards in the browser history.

Example:

window.onpopstate = function(event) {

console.log("location: " + document.location + ", state: " + JSON.stringify(event.state));

};

Other Options:

A . Window, location: location is an object containing information about the current URL.

C . Window, name: name is a property to set or get the name of a window.

D . Window, open: open is a method to open a new browser window or tab.


Reference:

MDN Web Docs - window.onpopstate

W3Schools - JavaScript History API



Which attribute is related to moving the mouse pointer of an element?

  1. Onmouseover
  2. Onmouseout
  3. Onmouseup
  4. onmouseenter

Answer(s): A

Explanation:

The onmouseover attribute in HTML and JavaScript is used to execute a script when the mouse pointer is moved over an element.

onmouseover Attribute: This event occurs when the mouse pointer is moved onto an element. It is commonly used to change styles or content of the element when the user interacts with it by hovering.

Usage Example:

<p onmouseover="this.style.color='red'">Hover over this text to change its color to red.</p>

In this example, the text color changes to red when the mouse pointer is moved over the paragraph.


Reference:

MDN Web Docs on onmouseover

W3C HTML Specification on Events



Viewing page 8 of 29
Viewing questions 36 - 40 out of 136 questions


Post your Comments and Discuss WGU Web-Development-Applications exam prep with other Community members:

AI Tutor AI Tutor 👋 I’m here to help!