Variables & Identifiers - Exercise 1

Question 1: Store and Update a Score

Declare a mutable score initialized from the argument, add 5 to it, and return the updated score.

Expected output: 17 (print this with console.log)

javascript

function updateStartingScore(startingScore) {
  // Write your solution here
}

console.log(updateStartingScore(12));

Question 2: Build an Identifier

Return the supplied non-empty words joined in camelCase, with the first word lowercase and the second capitalized.

Expected output: "userName" (print this with console.log)

javascript

function makeCamelIdentifier(first, second) {
  // Write your solution here
}

console.log(makeCamelIdentifier("user", "name"));

Question 3: Reassign a Quantity

Store the initial quantity in a let variable, replace it with the new quantity, and return it.

Expected output: 9 (print this with console.log)

javascript

function replaceQuantity(initial, replacement) {
  // Write your solution here
}

console.log(replaceQuantity(4, 9));

Question 4: Use Descriptive Bindings

Store the rectangle's width and height in local variables and return its area.

Expected output: 28 (print this with console.log)

javascript

function areaFromBindings(dimensions) {
  // Write your solution here
}

console.log(areaFromBindings({"width":4,"height":7}));

Question 5: Create a Full Name

Use a camelCase variable named fullName to join the two names with one space, then return it.

Expected output: "Ada Lovelace" (print this with console.log)

javascript

function joinFullName(firstName, lastName) {
  // Write your solution here
}

console.log(joinFullName("Ada", "Lovelace"));

Question 6: Calculate with a Constant

Declare a constant for 60 minutes per hour and return the number of minutes for the given hours.

Expected output: 180 (print this with console.log)

javascript

function hoursToMinutes(hours) {
  // Write your solution here
}

console.log(hoursToMinutes(3));

Question 7: Read a Hoisted Declaration

Read a var variable before its declaration, assign the supplied label, and return an array with its earlier typeof result and assigned value.

Expected output: ["undefined","ready"] (print this with console.log)

javascript

function readHoistedVar(label) {
  // Write your solution here
}

console.log(readHoistedVar("ready"));

Question 8: Keep a Block's Value Local

Create an outer value and a separate block-scoped value from the arguments. Return the outer value after the block.

Expected output: "outside" (print this with console.log)

javascript

function keepOuterValue(outer, inner) {
  // Write your solution here
}

console.log(keepOuterValue("outside", "inside"));

Question 9: Find a Binding's Type

Store the input in a local variable and return its typeof result.

Expected output: "boolean" (print this with console.log)

javascript

function typeOfBinding(input) {
  // Write your solution here
}

console.log(typeOfBinding(false));

Question 10: Compare Two Stored Codes

Store both inputs in local variables and return whether they are strictly equal.

Expected output: false (print this with console.log)

javascript

function compareStoredCodes(first, second) {
  // Write your solution here
}

console.log(compareStoredCodes("007", 7));