Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Adding a String
- // What I wish works:
- // 'hello ' + ' hello ' = 'hello hello '
- // JS uses '+' operator for string concatenation
- console.log('hello ' + 'hello ')
- // Subtracting a string
- // What I wish worked:
- // 'hello hello' - 'hel' = 'lo lo '
- // JS uses replace() for sring substitution
- console.log('hello hello '.replace(/hel/g, ''))
- // Multiplying a string
- // What I wish worked:
- // 'hello ' * 3 = 'hello hello hello '
- // JS uses repeat() for string repitition
- console.log('hello '.repeat(3))
- // Dividing a string
- // What I wish worked:
- // 'hello hello hello ' / 'hello ' = ['hello ', 'hello ', 'hello ']
- // JS uses split() for string splitting
- console.log('hello hello hello '.split(/(hello )/).filter(el => el))
Add Comment
Please, Sign In to add comment