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
| var userInput = prompt(“Enter a String:“); | |
| function ABCheck(str) { | |
| for(var i = 0; i < str.length; i += 1) { | |
| if (str[i] === ‘a’ || str[i] === ‘A’) { | |
| if (str[i+4] === ‘b’ || str[i+4] === ‘B’) { | |
| return true; | |
| } | |
| } | |
| else if (str[i] === ‘b’ || str[i] === ‘B’) { |
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
| //var userInput = prompt("Enter a number:"); | |
| var userInput = 7; | |
| function monkeyCount(n) { | |
| var result = '['; | |
| for(var i=1; i<=n; i+=1){ | |
| if(i!=n) { | |
| result += (i+", "); | |
| console.log(i); | |
| } |
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
| var userInput = prompt("Enter a String:"); | |
| function firstReverse(str) { | |
| var result = ''; | |
| for(var i=0; i<str.length; i++){ | |
| result+=str.charAt(str.length-1-i); | |
| } | |
| return result; | |
| } |
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
| var userInput = prompt("Enter a number:"); | |
| function opposite(number) { | |
| return Number(number)*-1; | |
| } | |
| console.log(opposite(userInput)); |
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
| var userInput = prompt("Enter a String:"); | |
| var makeString = function(s) { | |
| var result = ""; | |
| if (s[0] !== ' ') { | |
| result += s[0]; | |
| } | |
| for (var i = 1; i < s.length; i += 1) { | |
| if (s[i - 1] === ' ' && s[i] !== ' ') { | |
| result += s[i]; |
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
| var userInput = prompt("Enter a String:"); | |
| var longestWord = function(sen) { | |
| var slicedArr = sen.split(" "); | |
| var maximumString = ""; | |
| for (var i = 0; i < slicedArr.length; i += 1) { | |
| if (slicedArr[i].length > maximumString.length) { | |
| maximumString = slicedArr[i]; | |
| } | |
| } |
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
| function joinArrays(arr1, arr2) { | |
| // your code here | |
| var con = arr1.concat(arr2); | |
| return con; | |
| } | |
| var ar1 = [1, 2], | |
| ar2 = [3, 4]; | |
| console.log(joinArrays(ar1,ar2)); |
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
| function getAllLetters(str) { | |
| // your code here | |
| return Array.from(str); | |
| } | |
| //var output = ; | |
| console.log(getAllLetters("Radagast")); |
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
| function getAllWords(str) { | |
| // your code here | |
| return str.split(" "); | |
| } | |
| var output = getAllWords('Radagast the Brown'); | |
| console.log(output); |
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
| function getAllWords(str) { | |
| var emty = []; | |
| if(str.length!==0&&!/^\s/.test(str)) return str.split(" "); | |
| else return emty; | |
| //return emty,str.length,typeof(str); | |
| } | |
| var output1 = getAllWords('Radagast the Brown'), |