Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1 RMIT room numbers are numbered with the Building Name (i.e., a letter, one of A, B, C, D, E, F, G, H, I,

Question 1

RMIT room numbers are numbered with the Building Name (i.e., a letter, one of A, B, C, D, E, F, G, H, I, or K), followed by a 4-digit number. For example, H1044. In addition, a few rooms also have an optional final letter, for example: C1307A.

Write a function isValidRoomNumber that takes a string and returns true if it is formatted as a valid room number, and false otherwise. Calling isValidRoomNumber (H307) or isValidRoomNumber (3074H) should return false. Calling isValidRoomNumber (H3074) or isValidRoomNumber (H3074C) or isValidRoomNumber (K4444) should return true.

Question 2

Write a function fixRmitEmail(email). The function takes a RMIT email address (e.g., mp@myrmit.sg) and returns a new string with the following fixes applied:

Leading/Trailing whitespace removed

Any Capitalization of the @MyRmit.ca portion is removed (must be all lower case)

Any Capitalization of the username is left as is (dont change it)

fixRmitEmail( MPDinh@MyRmit.sg ) would return MPDinh@myrmit.sg

Question 3

Write a function subset(from, to), which takes two Number arguments and returns an Array of Numbers starting at from and ending at to (inclusive). If to is larger than from, return the empty array.

Calling subset(7,14) should return [7,8,9,10,11,12,13,14] and subset(100, 1) should return [].

Question 4

Given the following set of steps, write 3 different JavaScript implementations: 1) using a for-loop; 2) using a for-of loop; 3) using forEach():

An array named githubUrls contains strings with URLs of GitHub users (e.g., https://github.com/renedr)

Extract the username portion: https://github.com/renedr to `renedr`

Prepend the `@` symbol to the username: `@renedr`

Create a new array, githubUsers, with these @usernames

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Ai And The Lottery Defying Odds With Intelligent Prediction

Authors: Gary Covella Ph D

1st Edition

B0CND1ZB98, 979-8223302568

More Books

Students also viewed these Databases questions