Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. //- VIET HAM XOA N PHAN TU BEN TRAI CUA HAM CHO TRUOC
  2. const bai1 = (val, n) => {
  3. return val.slice(n);
  4. };
  5. //console.log('bai 1: ',bai1('asd',1));
  6. //- VIET HAM TINH THOI GIAN THUC THI Cua 1 HAM
  7. const bai2 = (fn) => {
  8. const result = fn();
  9. }
  10. console.log(bai2(() => 5+3));
  11. //- VIET HAM NHAN 1 URL CHUYEN URL THANH cac OBJECT
  12. //VD http://www.example.com?firstName=A&lastName=Nguyen
  13. const bai3 = (url) => {
  14. url = url.slice(url.indexOf('?')+1);
  15. return url.split('&')
  16. .map((v,i) => v.split('='))
  17. .map((v,i) => ( { [v[0]] : v[1] } ));
  18. }
  19.  
  20. //console.log('bai 3: ',bai3('http://www.example.com?firstName=A&lastName=Nguyen'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement