Question: So I have the following code

```
var processed;
fs.readFile(path, 'utf-8', function(err, data) {
    processed = false;
    //checking if text is in file and setting flag
    processed = true;
});

if (processed == true) {
    try {
        var fname = path.substring(path.lastIndexOf("\\") + 1);
        fs.moveSync(path, './processedxml/' + fname, {
            overwrite: true
        })
    } catch (err) {
        console.log("Error while moving file to processed folder " + err);
    }

}

```

But I don't get the desired output. Because looks like the readfile is executed by a separate thread and so the value of "processed" is not reliable.

I am not very familiar with nodejs so any help will be greatly appreciated.

Answer: 
```
int rec(int n)
{ 
  int sum = 0;
  if(n<=0)
    return 0;
  else if ((n%10)%2==0)
    sum = rec(n/10)+1;
  else
    sum = rec(n/10);

  return sum;
}

```

Maybe something like this :)
seems like you're trying to count the even digits in a number

```
int countEven(int n){
    if(n == 0) 
        return 0; //base case
    if (n<10)
        return !(n%2);
    return !(n%2)+countEven(n/10);
}

```