DEV Community

Discussion on: Multiply a string? 🤔

Collapse
debuqer profile image
Debuqer
"Hello world" * 2                 // ["Hello world", "Hello world"];
Enter fullscreen mode Exit fullscreen mode

so we have

["Hello world", "Hello world"] / 2           // "Hello world"
"Hello world" / 2              // ["Hello", "world"]
Enter fullscreen mode Exit fullscreen mode

so

["Hello world", "Hello world"]  / 4               
= "Hello world" / 2
= ["Hello", "world"]
Enter fullscreen mode Exit fullscreen mode

Ok Now lets multiply the result with 4 to see if we can get the the first value

["Hello", "world"] * 4 // is probably equals to
[["Hello", "world"], ["Hello", "world"], ["Hello", "world"], ["Hello", "world"]]
Enter fullscreen mode Exit fullscreen mode

Right?
Although I am not sure about what your new overloaded operation does, but the point is we can overload operators but first we need to know what that means. what does "*" really means for an array, or what are we talking about when we say "Hello world" can divide by 3.15?

Collapse
adam_cyclones profile image
Adam Crockett Author

My head, oh my head hurts 😂