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 sumFibs(num) { | |
| f1=1; | |
| f2=1; | |
| oddNumberSums = f1 + f2; | |
| f3=f1+f2; | |
| while (f3<=num) { | |
| if ((f3%2) > 0) { | |
| oddNumberSums +=f3; | |
| } | |
| f1=f2; |
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 spinalCase(str) { | |
| newString=str[0]; | |
| for (i=1;i<str.length;i++) { | |
| console.log(str[i]); | |
| if (str[i] == ' ' || str[i] == '_') { | |
| if (newString[newString.length-1]!='-') { | |
| newString+="-"; | |
| } | |
| } else if(str[i].toUpperCase()==str[i] && str[i]!=="-") { | |
| if (newString[newString.length-1]!='-') { |
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
| //Write your code below this line. | |
| function reverse(s){ | |
| return s.split("").reverse().join(""); | |
| } | |
| for(var i of my_array) { | |
| if (i == reverse(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
| // write the correct arrow function here | |
| var my_function = function(some_array) { | |
| return some_array.map(v => (v % 2 == 0 ? v + 1 : v - 1)); | |
| } |
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 findDay(myDate) { | |
| var dayStrArray = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] | |
| var pattern = /(\d{2})\/(\d{2})\/(\d{4})/; | |
| var dt = new Date(myDate.replace(pattern,'$3-$1-$2')); | |
| console.log(dayStrArray[dt.getDay()]); | |
| } |
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 convert(str) { | |
| // :) | |
| htmlEntities = [ | |
| ['&', '&'], | |
| ['<','<'], | |
| ['>', '>'], | |
| ['\'','''], | |
| ['"','"'], | |
| ]; | |
| myRegEx = /[^a-z\d]/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 unite(arr1, arr2, arr3) { | |
| return Array.prototype.slice.call(arguments).reduce(function(a,b) { | |
| for(i=0;i<b.length;i++) { | |
| if(a.indexOf(b[i])==-1) { | |
| a.push(b[i]) | |
| } | |
| } | |
| return a; | |
| }); | |
| } |
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 fearNotLetter(str) { | |
| for(i=0;i<str.length-1;i++) { | |
| if ((str.charCodeAt(i+1)-str.charCodeAt(i)) > 1) { | |
| return String.fromCharCode(str.charCodeAt(i)+1); | |
| } | |
| } | |
| } | |
| fearNotLetter("abce"); |
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
| pairs = [["A", "T"],["C","G"]] | |
| function pair(str) { | |
| tempArray = []; | |
| for (j=0;j<str.length;j++){ | |
| for (i=0;i<pairs.length;i++) { | |
| indexValue = pairs[i].indexOf(str.charAt(j)); | |
| if(indexValue==0) { | |
| tempArray.push(pairs[i].slice()); | |
| } else if (indexValue == 1) { | |
| pairs[i].reverse(); |
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
| import json | |
| def object_to_dict(obj): | |
| """ | |
| Method to get dict of object properties. This method identified object properties and returns | |
| a dict of properties with key, value as property name and property value respectively | |
| :param : object | |
| :return: obj_dict : dict | |
| """ | |
| obj_dict = {} | |
| print vars(obj.__class__) |