You are on page 1of 1

.

Given an array of integer numbers, compute how many values from the array are odd
and how many of them are even.

Example: for array [1,4,7,11,12] the returned result will be:

Odd values: 3

Even values: 2

Hint: Use the example that we did in the class, with calculating the maximum number
from a given array. Use two variables for storing the output results (e.g.
odd_values, even_values)

<script>
function tema(sir){
var even = 0;
var odd = 0;

for(var i = 0; i < sir.length; i++){


if ( sir[i] % 2 === 0){
even++
}
else
odd++

}
document.write("Total even numbers:" + even, "; ", "Total odd numbers:" + odd);
}
document.write(tema([1,2,3,10,11,12,13,14,16]));

</script>

2. Write a function that will take two strings as parameters and will return their
concatenation, with a space between it, all in upper case.

E.g. calling the function for strings: "happy" and "testing" will return "HAPPY
TESTING"

<script>
function tema2(a, b){
var c = a + " " + b;

return c.toUpperCase()
}
document.write(tema2("happy", "testing"));
</script>

You might also like