Skip to content

Instantly share code, notes, and snippets.

<script id="jsbin-javascript">
// Challenge 2: Validate a palindrome
//Return true if palindrome and false if not
function isPalindrome(str)
{
const revString = str.split('').reverse().join('');
return revString === str;
<script id="jsbin-javascript">
// Challenge 1: Reverse a string
// Return a string in reverse
// ex. reverseString('hello') === 'olleh'
function reverseString(str)
{
const strArr = str.split(' ');
strArray.reverse();
<script id="jsbin-javascript">
// Challenge 1: Reverse a string
// Return a string in reverse
// ex. reverseString('hello') === 'olleh'
function reverseString(str)
{
const strArr = str.split(' ');
strArray.reverse();
<script id="jsbin-javascript">
// Challenge 1: Reverse a string
// Return a string in reverse
// ex. reverseString('hello') === 'olleh'
function reverseString(str)
{
const strArr = str.split(' ');
strArray.reverse();
<script id="jsbin-javascript">
//What is the output?
var hero = {
_name: 'Amin Elhasan',
getSecretIdentity: function()
{
return this._name;
<script id="jsbin-javascript">
//What is the output?
console.log(typeof typeof 1);
//this returns string
</script>
<script id="jsbin-javascript">
//What is the ouput of this function
var num = 4;
function outer()
{
var num = 2
function inner()
{
num++;
<script id="jsbin-javascript">
//How to add something to the beginning and end of an array
var myArray = ['a','b','c','d'];
myArray = ["start", ...myArray]
myArray = [...myArray, "end"]
myArray = ["start",...myArray, "end"]
<script id="jsbin-javascript">
//How to add something to the beginning and end of an array
var myArray = ['a','b','c','d'];
myArray.push("end");
myArray.unshift("start");
console.log(myArray)
</script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>