I need help. I am taking an intro course in JS and I need help with some practice questions from my textbook that I can't get to work on my computer.

I have to write 3 functions with while loops in them. One to count the number of whitespaces in a string (my teacher recommended accessing it like an array but I haven't been able to do that), one that takes in two numbers and sees how many times the first goes into the second by adding, and the last one is to see if an array contains any positive numbers. My code is below for what I have done. I appreciate any guidance and assistance. Thanks!

Code:
count = 0;
var i = 0;

function howManySpaces(input) 
{
  while(i < input.length-1){
    if {(howManySpaces[index] = '')
      count++;
      i++ }
    else {
      i++ }
  }
}
Code:
var count=0;
var c=0;
function howManyFit(a, b) {
while ((b - c) >= a){
c = c + a;
count++;
}
return count;
}
Code:
Nothing for the positive check. I've been playing around with the modulus but haven't gotten it to work at all.