Created
May 28, 2017 13:21
-
-
Save leamsigc/b45fc8e38d697fe3c5066c0b5ea81f9a to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/ciwaqep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script> | |
| var str = "Bastian"; | |
| var target = "n"; | |
| var newstr =str.substr( str.length - target.length ,str.length -1); | |
| console.log(newstr); | |
| var v; | |
| if(target === newstr ){ | |
| var v= true; | |
| } | |
| else{ | |
| var v = false; | |
| } | |
| console.log(v); | |
| function confirmEnding(str, target) { | |
| // "Never give up and good luck will find you." | |
| // -- Falcor | |
| return str; | |
| } | |
| function repeatStringNumTimes(str, num) { | |
| // repeat after me | |
| if(num >= 0){ | |
| for(num;num>=0;num--){ | |
| str=str+str; | |
| } | |
| }else{ | |
| str = ""; | |
| } | |
| return str; | |
| } | |
| repeatStringNumTimes("abc", 3); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment