Do more with less code
- Convert ASCII values to alphanumeric characters
- Convert alphanumeric characters to ASCII
- Remove letters from exact position and return original string
Regular javascript
// convert string to it's ASCII value
str = ((str.charCodeAt() - 'A'.charCodeAt()) + rotation) % 26
// Get the alphanumeric value from ASCII
cipher.push(String.fromCharCode('A'.charChodeAt() + str))
// check if a string is uppercase
return string === string.toUpperCase()
// check if a string is lowercase
return string === string.toLowerCase()
Js-ord
1. // convert string to it's ASCII value
str = ((ord(str) - ord('A')) + rotation) % 26
---
2. // Get the alphanumeric value from ASCII
cipher.push(ordFrom(ord('A') + str))
---
3. // check if a string is uppercase
return isUpper(string)
---
4. // check if a string is lowercase
return isLower(string)
---
5. // remove string from exact position
const newString = shrink('Google', 2)
console.log(newString) // return 0
Enter the index of the letter you want to remove
Function accepts the following parameters:
1. the string you want to modify
2. the starting index
3. the ending index (if you do not specify, every element from the starting index will be removed)
const aString = shrink('Bolossom', 2, 3)
console.log(aString) // Boom
---
6. //converts string to its palindrome
const palindrome = isPalindrome('blossom')
console.log(palindrome) // 'mossolb'
npm install js-ord
const
{ord, ordFrom,
isUpper, isLower,
shrink, isPalindrome} = require('js-ord')
console.log(ord('a')) // 97
console.log(ordFrom(97)) // a
Contributions, issues and feature requests are welcome!
🌸 Blossom
- Github: @blossom-babs
- LinkedIn: Blossom Babalola
- Twitter: @BlossomBabalola
- Give a ⭐ if you like this project