Category Archives: Performance tasks

JavaScript prototype addTen

Function.prototype.myBind = function (...args) {
  const func = this;
  return function (...innerArgs) {
    return func.apply(this, args.concat(innerArgs));

function add(num1, num2) {
  return num1 + num2;

const addTen = add.myBind(10);

console.log(addTen(5)); // Now it should return 15

Tricky questions

Orange Kangaroo In Denmark

Effect: A person is given a few instructions with a seemingly unlimited choice of answers. They are instructed not to reveal their chosen answers. You should then be able to predict what that person had been thinking of, to everybody's amazement.

Method : Read out the following instructions to your friend and get them to think of the answer as soon as possible. ( They may want to scribble some notes on paper to make the task easier. )

  • Think of a number from 1 to 10.
  • Multiply that number by 9.
  • If the number is a 2-digit number, add the digits together.
  • Now subtract 5.
  • Determine which letter in the alphabet corresponds to the number you ended up with (example: 1=a, 2=b, 3=c, e.t.c.)
  • Think of a country that starts with that letter.
  • Remember the last letter of the name of that country.
  • Think of the name of an animal that starts with that letter.
  • Remember the last letter in the name of that animal.
  • Think of the name of a fruit that starts with that letter.

You can then ask them if they are thinking of a Kangaroo in Denmark eating an Orange?

This is a really cool prediction trick that should work most of the time. The secret is in the instructions. By instruction 3 your friend will always have come up with the number 9. Subtracting 5, leaves you with he the number 4. The number 4 is then converted to the letter D.

From here it is down to a question of probability, as Denmark is by far the most common choice that people tend to think of. Further on when they are trying to think of an animal beginning with K, again Kangaroo is by far the most common choice although you may very occasionally be caught out with a Koala or Kiwi as an answer.

This cool magic prediction trick is meant as a light hearted bit of amusement and can really catch people out, leaving them wondering if you can actually read their mind.

Connect 9 dots with 4 lines

Connect 4 dots with a triangle

3 glasses and one is upside down

Turn then all up in 3 moves by flipping 2 glasses at a time

Lily in the pond

In a pond, there is a patch of lily pads. Each day, the lily pads double in size. If it takes the lily pads 48 days to cover the whole pond, how many days does it take to cover half the pond?
Answer: 47 days. Whatever day the lily pads covered half the pond, the whole pond would be covered the next day.

Arm coordination

Twist arms and lock them in front of you. Turn the arms lock to be in front of your face.
Now move one finger after another.

General coordination

Touch your pointer fingers in front of you.
Now close one eye and do the same.

How many holes does the t-shit have?

Add the hole at the front side which is the same hole on the back side. Usually person is forgetting 4 extra holes for arms, head and body.

Can you spot
spot a mistake here?

If I ran in a marathon and I overtook the person in 2nd place what place would I be in?

Old lady, friend and girl on bus stop

You’re driving down the road in your car on a wild and stormy night. The weather is like a hurricane, with heavy rains, high winds, and lightning flashing constantly. While driving, you come across a partially-covered bus stop, and you can see three people waiting for a bus:

  • An old woman who looks as if she is about to die.
  • An old friend who once saved your life.
  • The perfect partner you have been dreaming about (your “soulmate”).

Knowing that you only have room for one passenger in your car (it’s a really small car), which one would you choose to offer a ride to? And why?

Answer: “I would give the car keys to my old friend, and let him take the old woman to the hospital. Then I would stay behind and wait for the bus with the partner of my dreams.”

Trolley problem

You see a runaway trolley moving toward five tied-up (or otherwise incapacitated) people lying on the tracks. You are standing next to a lever that controls a switch. If you pull the lever, the trolley will be redirected onto a side track, and the five people on the main track will be saved. However, there is a single person lying on the side track. You have two options:

  • Do nothing and allow the trolley to kill the five people on the main track.
  • Pull the lever, diverting the trolley onto the side track where it will kill one person.

Which is the more ethical option?

Do circle with one hand and square with another.

It is impossible. The left side of the brain gives commands to right hand and vice versa. So tho brains are conflicting.

Try to guess without calculating how many days average person live. Answer: 28,000

Say 50 words in 20 seconds without letter A

Say all numbers. First number with A is thousand.

Men needs to cross the river on boat

Fox, chicken and grain.
Boat can fit only man and one item.
You cant leave fox and chicken, or chicken and grain together.

React Like button

import cx from 'classnames';
import { Component } from 'react';

export default class LikeButton extends Component {
    state = {
        count: 100,
        liked: false
    likeMe = () => {
        let newCount;
        if(this.state.liked) {
            newCount = this.state.count - 1;
        } else {
            newCount = this.state.count + 1;

          count: newCount,
          liked: !this.state.liked
    render() {
        return (
                    className={`like-button ${this.state.liked ? "liked" : ""}`}
                    >Like | <span className={`likes-counter`}>{this.state.count}</span></h1>
                    .like-button {
                        font-weight: normal;
                        cursor: pointer;
                        font-family: Helvetica, Arial, Sans-Serif;
                        font-size: 1rem;
                        padding: 5px 10px;
                        color: #585858;
                        border: 1px solid #585858;
                        display: inline-block;
                   .liked {
                        font-weight: bold;
                        color: #1565c0;
                        border-color: #1565c0;


Given a number n, for each integer i in the range from 1 to n inclusive, print one value per line as follows:

  • If i is a multiple of both 3 and 5, print FizzBuzz.
  • If i is a multiple of 3 (but not 5), print Fizz.
  • If i is a multiple of 5 (but not 3), print Buzz.
  • If i is not a multiple of 3 or 5, print the value of i.

Function Description

Complete the function fizzBuzz in the editor below.

fizzBuzz has the following parameter(s):

int n: upper limit of values to test (inclusive)

Returns: NONE


The function must print the appropriate response for each value i in the set {1, 2, ... n} in ascending order, each on a separate line.


  • 0 < n < 2 × 105

Input Format for Custom Testing

Input from stdin will be processed as follows and passed to the function.

The single integer n, the limit of the range to test: [1, 2, ...n].

Sample Case 0

Sample Input

STDIN    Function
-----    --------
15    →  n = 15

Sample Output



The numbers 3, 6, 9, and 12 are multiples of 3 (but not 5), so print Fizz on those lines.

The numbers 5 and 10 are multiples of 5 (but not 3), so print Buzz on those lines.

The number 15 is a multiple of both 3 and 5, so print FizzBuzz on that line.

None of the other values is a multiple of either 3 or 5, so print the value of i on those lines.

function fizzBuzz(n) {
	var i, res = '';
	for( i=1; i <= n; i++ ) {
		res = '';
		if( i % 3 == 0 ) {
			res += 'Fizz';
		if( i % 5 == 0 ) {
			res += 'Buzz';
		if( res == '' ) {
			res = i;

Get the week day later

Variable weekDaysList holds a list of weekdays, which are represented as strings.
Write a function that have 2 params:

  • weekDayCurrent (STRING) - representing the day of the week for the current day
  • and weekDaysLater (INTEGER) - representing how many days later

For example: if weekDayCurrent = “Tuesday” and weekDaysLater = 4, the function should return “Saturday”.

function weekDayLater(weekDayCurrent, weekDaysLater) {
  let weekDaysList = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
  // get the index of the weekday
  let weekDayIndex = weekDaysList.indexOf(weekDayCurrent); 
  // get the index offset
  let moduloIndex = (weekDayIndex + weekDaysLater) % weekDaysList.length;
  return weekDaysList[moduloIndex];