- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
<!--
#1
When the button is clicked, all prices should change to 199
-->
<span class="price">299</span>
<span class="price">299</span>
<span class="price">299</span>
<button id="mybutton">Click me</button>
<script>
var elem = document.getElementById('mybutton');
function onClick(e){
target our class "price", and then change that value to 199;
elem = 199;
}
</script>
<!--
#2
Write a function that takes in a name and spits out "Hello [name]" in the output div
-->
<div id="output"></div>
<script>
</script>
<!--
#3
Find the largest and smallest number in an unsorted integer array
-->
<script>
const nums = [1, 2, 6, 12, 9];
nums.sort((a,b) => a - b);
const smallestNum = nums[0];
const largestNum = nums[nums.length - 1];
</script>
<!--
#4
Find the missing number in a given integer array of 1 to 100
it is sorted
it should have every but its missing one number from 1 - 100
compare to the previous number to current numbers difference. this difference should be 1
-->
<script>
if(nums.length <= 1) {
return
}
for(let i = 1; i < nums.length; i++) {
let difference = nums[i] - nums[i-1];
if(difference !== 1){
return (nums[i] - 1);
}
}
return null;
</script>