I have a method with a forEach loop.
This works fine and shows a result list.
Here is the code:
test() {
os.cpus().forEach(el => {
if (el.model.search('Intel') === 0) {
return el.model.match(/i(.*)-/)[1];
}
});
}
The forEach has a return and the method return undefined.
I know I need to do a callback
but I just don't know how to do this in this code.
How can I get test()
to return the result?