Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String into Int returns NaN? #17

Closed
drolsen opened this issue Nov 12, 2016 · 3 comments
Closed

String into Int returns NaN? #17

drolsen opened this issue Nov 12, 2016 · 3 comments

Comments

@drolsen
Copy link

drolsen commented Nov 12, 2016

Unable to convert a string to int and return it.

var options = {
    functions: {
        parseInt: function (value) {
		return parseInt(value);
        }
    }
};
.selector {
	XXXX: parseInt("12");
}

returns NaN in my sheet?

@andyjansson
Copy link
Owner

Hello. Sorry for the late reply, I've been away over the weekend.
Have you tried passing in the value without the quotes?

@drolsen
Copy link
Author

drolsen commented Nov 14, 2016

Yes giving a number to the function gives me a number back, but the purpose of this function will be to turn strings and floats into whole numbers for further functionality needs in my sheets. Are we locked into using a single data type for passing and returning?

@andyjansson
Copy link
Owner

A CSS declaration's value is always going to be a string. When you call parseInt("12"), that will be the equivalent of doing parseInt("\"12\"") in JavaScript. Whenever you read a value from the declaration, it will be as a string, and whenever you return a value back to the declaration, it will be stringified to be inserted back into the declaration's value string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants