I am a newbie here. I had a technical assessment the other day and had a coding question where I had to write a function that took two arguments, a sentence and a word. The function had to count how many times the word was repeated in the sentence. I have managed to get the answer doing it the first way you see below but cannot for the life of me seem to figure it out as a function that takes 2 arguments which is what the task asked for. Can anyone tell me where I am going wrong please?

```js
let count = 0;
let str = "hello hello hello Bob is my name so it is hello"
let query = "hello";
let array = str.split(" ")
for (let i = 0; i < array.length; i++) {
  if (array[i] === query) {
    count++;
  }
}
console.log(count);
```

```js
let str = "hello my name is my my bob";
let word = "my";

function countWord(str, word) {
  let count = 0;
  let strArray = str.split(" ");
  let array = strArray;
  for (let i = 0; i < array.length; i++) {
    if (array[i] === word) {
      count++
    }
  }
}
console.log(countWord(str, word));
```