I'm trying to remove a whitespace from a numerical value representing money.
For example, I want 1 000 kr
to be 1000
. This is the same case for when the currency is 10 000
I'm using this function to remove the kr
but when I try to add another .replace
it does not work:
Cypress.Commands.add('currency', (selector) => {
cy.get(selector)
.children()
.eq(1)
.invoke('text') // get text
.then((text) => +text.replace('kr', '').trim());
});
How would I add another .replace to remove the extra spacing from the numerical value?