1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 13:35:07 +00:00

LibJS: Implement Math.abs()

This commit is contained in:
Andreas Kling 2020-03-29 14:56:28 +02:00
parent 2285f84596
commit 2d3634d5f5
4 changed files with 46 additions and 1 deletions

View file

@ -114,9 +114,12 @@ Value Value::to_number() const
case Type::Null:
return Value(0);
case Type::String: {
auto& string = as_string()->string();
if (string.is_empty())
return Value(0);
bool ok;
//FIXME: Parse in a better way
auto parsed_int = as_string()->string().to_int(ok);
auto parsed_int = string.to_int(ok);
if (ok)
return Value(parsed_int);