How to delete keys == null

Hello, I am trying to remove the values equal to null on my json. Despite the many solutions proposed on the different forums there is no solution on n8n. Here is the code I found. I tried to adapt it but it does not work. I want to specify that I am in a function items.

Hi @simon_Piquemal

You were almost there. Just need to define the key you are checking. This can be done by looping the keys.

for (const key in item) {  
  if(item[key]===null){
    delete item[key];
  }
}
return item;

fanstastic, it works
thank you @BramKn

and on a more classical function?
I tested on a classic function with For each with an example of incrementing a value that works well but to override the null value nothing happens.

Hey @simon_Piquemal,

On a normal function node as it runs for all items you would probably need to use item.json otherwise it will just do one loop.

correct thank you very much works well now