# Category Archives: JavaScript

## Problem: There are N prisoners standing in a circle, waiting to be executed…

By | June 27, 2023

There are N prisoners standing in a circle, waiting to be executed. The executions are carried out starting with the kth person, and removing every successive kth person going clockwise until there is no one left. Given N and k, write an algorithm to determine where a prisoner should stand in order to be the… Read More »

## Given a sorted array, find the smallest positive integer that is not the sum of a subset of the array.

By | June 27, 2023

Java public class SmallestPositiveInteger {    public static int findSmallestPositiveInteger(int[] nums) {        int smallest = 1;        for (int num : nums) {            if (num <= smallest) {                smallest += num;            } else… Read More »

## How to Refresh a HTML Page Using JavaScript ?

By | April 26, 2012

Hi, Most probably you may have encountered a situation where you have to refresh the web page in your code. Here is, how it could be done using JavaScript. Sample Refresh Here on button click it will call the function ‘refresh_yourPage()’, and it will refresh the page! 🙂

## Trim a string in Javascript.

By | March 29, 2012

Below is a simple function to implement this.

## Passing a Value to a Function in JavaScript – An Example

By | August 2, 2011

Hi, Given below, is an example for passing a value to a function in JavaScript.

## Converting String to Upper Case in JavaScript

By | August 2, 2011

Hi, For converting a string to upper case in javascript, use the following code. It will give you ‘CODERZHEAVEN’ 🙂

## How to load a PDF in Titanium?

By | March 3, 2011

Loading a PDF file in Titanium may be sometimes our requirement for an application. For loading a PDF we need to have a webview inside a scrollview so that it is scrollable also. Take a look at this simple example. /** creating a window **/ var window = Titanium.UI.createWindow{}; /** creating a webview **/ var… Read More »

## Client Side Form Validation – using JavaScript

By | March 1, 2011

Hi, JavaScript is mainly used for client side scripting. In client side scripting one of the thing which we are usually in need is Validation of Forms. We want to know the user , who is interacting with the form have already given the necessary details before submitting or saving etc. Here is a simple… Read More »

## Using Arrays in JavaScript – Basics

By | February 28, 2011

Hi… We all know, Arrays are nothing but variables which can hold all your variable values with a single name. Let’s see some basic operations of Arrays in JavaScript. To Create a New Array. Use the following code. var myArray = new Array(); This code of line created a new Array object called myArray. Adding… Read More »