- Fork and clone this repository.
- Change into the new directory
cd w01d03-HW2
- Create a file called solution.js and add all answers to it.
Research 3 string methods and describe what they are used for and how to use them. You can find string methods here https://www.w3schools.com/js/js_string_methods.asp
Method 1
Name:
Description:
Example using it:
Method 2
Name:
Description:
Example using it:
Method 3
Name:
Description:
Example using it:
Where can you print out the value of variable c without resulting in an error?
var a = 1;
function x() {
var b = 2;
function y() {
var c = 3;
function z() {
var d = 4;
}
z();
}
y();
}
x();
- anywhere in the script!
- anywhere inside the function
x()
- anywhere inside the function
y()
- anywhere inside the function
z()
- Write a function that chooses two random numbers (1-6) and returns them. It should also return the sum.
- Example:
rollDice() // Dice rolled are 6 and 1. Sum is 7
- BONUS: have your function take an argument of the # of dice to be rolled.
- Example:
rollDice(3) // Dice rolled are 4, 2, and 7. Sum is 13.
- Write a function
currencyConverter
that takes two arguments an amount and a currency (USD, GBP, EGP, BD) and returns the converted version of the amount in Riyals. - Use the if-then-else construct available in Javascript. Hint :
- 1 Riyal = 4.68 Egyptian pound
- 1 Riyal = 0.10 Bahraini dinar
- Write a function
isCharacterAVowel
that takes a character (i.e. a string of length 1) and returns true if it is a vowel and false, otherwise.
- Define a function
pow
that replicates the Math.pow() method in JavaScript's Math object.
- When finished,
git add .
,git commit -m " "
,git push origin master
to your fork and submit a pull request. - Please fill up the following questions when you pull request:
- on a scale from 1 to 5, how comfortable were you with this assignment? (1 is very difficult)
- How long did it take?
- What was a challenge you had with this assignment?
- Is there anything that you'd like some further information on?
- Do you have any suggestions to improve this assignment?