parent
600d84301d
commit
3f8b6dd0d7
@ -0,0 +1,31 @@
|
|||||||
|
# W02D02 Morning Warmup
|
||||||
|

|
||||||
|
|
||||||
|
####Exercises 1: Find a value in a given array
|
||||||
|
- Write a function `searchArray` that takes an array and value as parameters and searches the array for the given value. If the value is in the array, return `true`, otherwise return '-1'.
|
||||||
|
```javascript
|
||||||
|
var nums = [1,2,3,4,5]
|
||||||
|
searchArray(nums, 3) => true
|
||||||
|
searchArray(nums, 6) => -1
|
||||||
|
```
|
||||||
|
Here is some starter code:
|
||||||
|
```javascript
|
||||||
|
var searchArray = function(array,value) {
|
||||||
|
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Exercises 2: Determine whether a given string is a [palindrome](https://en.wikipedia.org/wiki/Palindrome)
|
||||||
|
|
||||||
|
- Write a function `isPalindrome` that takes in a single parameter `str`, a string, and returns `true` if the string is a palindrome, and false otherwise. For example
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
isPalindrome('hello') => false
|
||||||
|
isPalindrome('hannah') => true
|
||||||
|
```
|
||||||
|
Here is some starter code:
|
||||||
|
```javascript
|
||||||
|
var isPalindrome = function(str) {
|
||||||
|
|
||||||
|
};
|
||||||
|
```
|
||||||
Loading…
Reference in new issue