Hello @Cumatale,
The pnp functions are running async. The console.log("outside of sp.web.lists.getByTitle: " + globalVariable); runs before the function finishes and so it is equal 0.
You can add .then() to keep code running in order, like this:
fd.spRendered(function() {
window.globalVariable = 0;
sp.web.lists.getByTitle("DRUO_LSHEET").items.get().then(function(items) {
//items count
globalVariable=items.length;
console.log("inside of sp.web.lists.getByTitle: " + globalVariable);
}).then(function() {
console.log("outside of sp.web.lists.getByTitle: " + globalVariable);});
});