Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Questions about Javascript

Featured Replies

what is the is the purpose for using parseInt and parseFloat?

 

and what does actually the return function does?

 

for example on this code here:

var foo = doSomething(5 , 6);
var bar = doSomething(1, 5);

function doSomething(paramOne, paramTwo) {
	paramOne = paramOne + 5;
	paramOne = paramOne + 1;
	paramOne = paramOne -1;

	return paramOne + paramTwo;
}

alert(foo);
alert(bar);

 

The return statement 'returns' a value/object/statement etc. When you use the return statement, it makes the value that you return available when/if you ask for it.

 

Think of if like a persons hand passing round some paper with information on it. The hand passing the information but another persons hand needs to pick it up and look at it for it to be read/understood.

 

Examples:

 

function a() {

 

console.log("A value");

 

}

 

function b() {

 

return 'A value';

}

 

calling a() output:

 

A value

 

calling b() output:

 

nothing UNLESS you use something like console.log(b());

 

parseint will take a string and return an integer. Javascript can handle numbers a bit unexpectedly to watch out.

parse float does the same but for floating point numbers.

 

If you don't understand float/numbers etc look up Javascript types :)

Edited by Mr Ben

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.