We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to reverse a string in JavaScript
const str = "hello" str.split('').reverse().join('') //"olleh"
const str = "hello" [...str].reduce((prev,next)=>next+prev) //"olleh"
function reverseString(str){ const arr = [...str] let reverse= ""; while(arr.length){ reverse = reverse + arr.pop() } return reverse }
How to clear an array in javascript
var arr = [1,2,3,4,5,6] arr = [ ] console.log(arr) //empty array [ ]
var arr = [1,2,3,4,5,6] arr.length = 0 console.log(arr) //empty array [ ]
var arr = [1,2,3,4,5,6] while(arr.length){ arr.pop() } console.log(arr) //empty array [ ]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
翻转字符串
How to reverse a string in JavaScript
清空数组
How to clear an array in javascript
The text was updated successfully, but these errors were encountered: