---
# System prepended metadata

title: Exam
tags: [exam]

---

# Exam

###### tags: `exam`

/**
 * Write a function that returns a password whose length is passed as a parameter.
 */

/**
 * The generated password must be at least 3 characters long.
 *  Password must comply with
 *  at least three of the following four character categories:
 *  - Contain at least one uppercase character (A-Z).
 *  - Contain at least one lowercase character (a-z).
 *  - Contain at least one digit (0-9).
 *  - Contain at least one symbol (~!@#$%^&*_-+=`|(){}[]:;"'<>,.?/).
 */

/**
 * Case 1:
 * Input is not an integer.
 * For input:
 * passwordGenerator(null) or
 * passwordGenerator(undefined) or
 * passwordGenerator({}) or
 * passwordGenerator([]) or
 * passwordGenerator('') or
 * passwordGenerator(' ') or
 * passwordGenerator('abc') or
 * passwordGenerator('16.1') or
 * passwordGenerator(16.1)
 * Expected Output: 'Not an Integer'
 *
 * Case 2:
 * Input is less than 3.
 *
 * For Input:
 * passwordGenerator(2) Expected Output: 'Minimum length allowed: 3'
 *
 * Case 3:
 * Output is a string with desired length and complies
 * with at least three of the four character categories.
 *
 * For Input:
 * passwordGenerator(16) Expected Output: 8t=(eUz1/G*N;?v_ (Password as example)
 */

/**
 * - The name of the method to perform the task is already provided
 *   with the correct definition of name and parameters
 *   (passwordGenerator(charsQuantity)).
 * - The charsQuantity parameter must always be a number.
 * - RegExp can be used.
 */

/**
 * You would like to make a list of N top brand names
 * for a specific user based on his/her preferences.
 *
 * The method of compiling the list is as follows:
 * 1. Every user has a list of brands he/she likes most.
 *    If there are at least N liked brands,
 *    take the first N brand names from the list.
 *
 * 2. There are lists of brands which are most popular
 *    among the users of each gender.
 *    If the user's list does not have enough liked brands,
 *    then the rest of the result list
 *    should be filled up with top brands from list for the user's gender.
 *
 * 3. If the user's individual preference list
 *    and the list for that user's gender combined do not provide enough brands,
 *    you should finish with an error.
 *
 * Write a function:
 *    function solution(U, N);
 *
 * that, given user U and the nmber of brand names N,
 * returns a Promise that should either be:
 *
 * - resolved with an array of exactly N top brand names for the given user,
 *   in the following format:
 *   ["Some Brand Name", "Other Brand Name", ...]; or
 *
 * - rejected with a CustomError with the message
 *  "Not enough data"
 *  (if there are fewer than N brand names to be listed,
 *   or both Promises getLikedBrands(id) and getTopBrandsForGender(gender) are rejected).
 *
 * Technical details:
 *
 * Accessing data:
 * - The user parameter is an object of the following structure:
 *   { id: 123132, gender: "FEMALE" },
 *   where id is an integer and gender is a string containing either "FEMALE" or "MALE".
 *
 * - The brand names liked by a specific user can be accessed
 *   by calling the function getLikedBrands(id).
 *
 * - The list of brands for a gender can be obtained
 *   by calling the function getTopBrandsForGender(gender).
 *
 * - The functions return Promises,
 *   that will be rejected or resolved with data in the following format:
 *   [
 *      { id: 123, name: "Some Brand Name" },
 *      { id: 456, name: "Other Brand Name" },
 *      ...
 *   ]
 *
 * The result:
 * - The order of the brand names in the result list
 *   should be the same as the order in the lists produced by the functions,
 *   with brand names returned by getLikedBrands(id) listed first.
 *
 * - Brand names returned by
 *   both functions getLikedBrands(id) and getTopBrandsForGender(gender) in combination,
 *   should appear in the result list only once.
 *
 * Examples:
 * Given user U,
 * assume that getLikedBrands(U.id) returns
 * [
 *    { id: 1, name: "Logestyx" },
 *    { id: 10, name: "Gladlear" }
 * ]
 * and getTopBrandsForGender(U.gender) returns
 * [
 *     { id: 6, name: "Burylaze Slapgalt" },
 *     { id: 1, name: "Logestyx" },
 *     { id: 7, name: "Izarpure" }
 * ].
 *
 * 1. For N=1,
 *    your function should return a Promise
 *    which resolves with an array ["Logestyx"].
 *
 * 2. For N=3,
 *    Promise should be resolved
 *    with an array
 *    [ "Logestyx", "Gladlear", "Burylaze Slapgalt"].
 *
 * 3. For N=4,
 *    Promise should be resolved
 *    with an array
 *    ["Logestyx", "Gladlear", "Burylaze Slapgalt", "Izarpure"].
 *
 * 4. For N=5,
 *    Promise should be rejected with a CustomError.
 *
 */





/**
 * Your task is to implement a React component
 * that renders a running-clock
 * that will count down time
 * until it reaches 0 minutes and 0 seconds (00:00).
 *
 * Requirements
 * Functionality
 *
 * Given the HTML structure:
 * <label>
 * 		<input type="number">
 * 		Minutes
 * </label>
 * <label>
 * 		<input type="number">
 * 		Seconds
 * </label>
 *
 * <button>START</button>
 * <button>PAUSE / RESUME</button>
 * <button>RESET</button>
 *
 * <h1 data-testid="running-clock">00:00</h1>
 *
 * implement a running-clock that receives its time value from user inputs
 * and allows the user to start, pause/resume the countdown and reset the clock.
 *
 * In order to satisfy the task's requirements,
 * you need to implement the following:
 *
 * 1. Time display:
 * 		- time is displayed in <h1 data-testid="running-clock">
 * 		and its initial value is 00:00;
 * 		- time is displayed in mm:ss format;
 * 		- 1 minute, 5 seconds should be displayed as: 01:05;
 * 		- 1 minute, 65 seconds should be displayed as: 02:05.
 *
 * 2. Inputs:
 * 		- changing input values does not change the value
 * 			displayed in <h1 data-testid="running-clock">;
 * 		- inputs do not need to have max or min attributes;
 * 		- the clock doesn't need to handle negative values;
 * 		  this is not a part of the solution and will not be evaluated.
 *
 * 3. Behavior:
 * 		1. On a START button click,
 * 			 set the clock value displayed in <h1 data-testid="running-clock">
 * 			 with the time calculated from the inputs and start counting down
 * 		2. Once the clock is running,
 * 			 update the displayed time every second
 * 		3. Once the clock is running and the START button is clicked,
 * 			 restart the clock with the same time originally provided in the inputs
 * 		4. Once the countdown is done and the clock reaches 00:00,
 * 			 stop counting and keep displaying 00:00
 * 		5. On a PAUSE / RESUME button click,
 * 		   pause or resume the clock appropriately:
 * 		   - PAUSE puts the countdown on hold
 * 		   - RESUME resumes the countdown from where it left off
 * 		6. Once the RESET button is clicked,
 * 			 both inputs should be reset to 0
 * 		7. Once the RESET button is clicked,
 * 			 the time displayed in <h1 data-testid="running-clock">
 * 			 should be reset to 00:00.
 *
 * Implementation hints & notice:
 * - Do not clear the inputs on a START button click.
 * - Use the same button element for both pause and resume actions.
 * - The following elements are used in tests and therefore must not be changed:
 *   - <input> labels
 *   - <button> texts
 *   - <h1>element data-testid attribute value.
 *
 * Hints
 * - Only imports from the react module are allowed.
 * - Your solution will be evaluated based on its correctness.
 * - Design/styling is not assessed and will not affect the score.
 *   You should focus only on implementing the requirements.
 * - The Preview tab will display your component.
 *   You can use it for testing purposes.
 * - You can use console.log and console.error for debugging purposes
 *   via your browser's developer tools.
 */

