Basic Knowledge - Exercise 2

Question 1: Make a Welcome Line

Return "Welcome, " followed by the name and an exclamation mark.

Expected output: "Welcome, Sam!" (print this with console.log)

javascript

function makeWelcomeLine(name) {
  // Write your solution here
}

console.log(makeWelcomeLine("Sam"));

Question 2: Count a Word's Characters

Return the length of the supplied ASCII word.

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

javascript

function countWordCharacters(word) {
  // Write your solution here
}

console.log(countWordCharacters("planet"));

Question 3: Read the First Letter

Return the first character of a non-empty string.

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

javascript

function readFirstLetter(text) {
  // Write your solution here
}

console.log(readFirstLetter("hello"));

Question 4: Read the Last Letter

Return the last character of a non-empty string.

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

javascript

function readLastLetter(text) {
  // Write your solution here
}

console.log(readLastLetter("river"));

Question 5: Clean a Username

Remove whitespace from the beginning and end of the supplied username.

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

javascript

function trimUsername(username) {
  // Write your solution here
}

console.log(trimUsername("  sunny  "));

Question 6: Create an Uppercase Label

Return the supplied label in uppercase.

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

javascript

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

console.log(uppercaseShelfLabel("books"));

Question 7: Create a Lowercase Tag

Return the supplied tag in lowercase.

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

javascript

function lowercaseSearchTag(tag) {
  // Write your solution here
}

console.log(lowercaseSearchTag("JAVASCRIPT"));

Question 8: Join Address Parts

Join the street and city using a comma followed by one space.

Expected output: "Oak Street, Leeds" (print this with console.log)

javascript

function joinAddressParts(street, city) {
  // Write your solution here
}

console.log(joinAddressParts("Oak Street", "Leeds"));

Question 9: Repeat a Reminder

Return the supplied word repeated the given non-negative integer number of times, with no separator.

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

javascript

function repeatReminderWord(word, count) {
  // Write your solution here
}

console.log(repeatReminderWord("go", 3));

Question 10: Build an Email Subject

Return "Order " followed by the order number and " shipped".

Expected output: "Order 42 shipped" (print this with console.log)

javascript

function orderShippedSubject(number) {
  // Write your solution here
}

console.log(orderShippedSubject(42));