Skip to content

Instantly share code, notes, and snippets.

@minmaxdata
Created March 6, 2015 18:58
Show Gist options
  • Save minmaxdata/24c37fa68a9a73664bf2 to your computer and use it in GitHub Desktop.
Save minmaxdata/24c37fa68a9a73664bf2 to your computer and use it in GitHub Desktop.
interview notes
// ************************************************************************************************
// What Javascript methods would convert the string "20" to an integer (on the fly) so "20" + 20 = 40?
"20"+20 = "2020"
parseInt('20') + 20;
"20"*1
+"20"+20
// ************************************************************************************************
(function() {
console.log(1);
setTimeout(function(){console.log(2)}, 0);
setTimeout(function(){console.log(3)}, 0);
console.log(4);
})();
// In what order are they printed and why?
1
4
3
2
// ************************************************************************************************
// Write all the methods you know to go through an array, native or not
// ************************************************************************************************
// Write all the data types in JS
null
undefined
string
number
array
object
boolean
// ************************************************************************************************
// Write a function that returns if a string is a palindrome or not
// sonia: not palindrome
// anna: palindrome
function isPalindrome (string) {
var length = string.length;
var stringArray = string.split(‘’).reverse().join('');
for (var i = 0; i < length ; i++) {
if (stringArray[i] == stringArray((length-1) - i)) {
return true;
} else {
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment