A happy ticket is a ticket with such a serial number that the sum of the first three digits is the same as the sume of the last three digits.
For example, ticket number 385916 is a happy ticket, since 3 + 8 + 5 = 9 + 1 + 6
Implement and export as default a function that verifies the happiness of a ticket.
This function should return
true if the ticket is happy, and
isHappyTicket(385916); // true isHappyTicket(231002); // false isHappyTicket(128722); // true
Convert a number to string using
String like so:
String(1234); // "1234"
Convert a string back into a number using
Number like so:
Number("456"); // 456
length value to find out the length of a string:
'welcome'.length; // 7
Use the substr method to get a substring:
'foo'.substr(1, 2); // 'oo';
For full access to the challenge you need a professional subscription.
A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.