You are on page 1of 16

JAVASCRiPt >Developed by Brndan Aick

Typeof Opeat: hnay operator · placad befove operamol


to detami ne the data type f om opehomo.
will Yaturn number

Sub stuing); Exhac the charactu bom atfing, between turo


speeified ucties.
eveNse C) Kevses the ordr ot om elanen in am

WCode for OK bton to nd tength of nam anteed in text box:


<html>
< head>
<seipt >
tunction Myfun ction ()
vaY shr,
st pro mpt ("enr yauy name")
docu ment.Lorita (" he longtn of sÙivg' t st. langth))
</seipt> (/had></htmt>
WCmbeddinq cuYYMt date md time
VaY d= new Date C);
aoumeyt.wnte (d)

VCoda to display vst fpus lhractus

<seupt>
funtion Myfuntion )
2 vaYs s prompt ('entu);
VaY str. subsbinglo,4))
doumet. write ("n");

</suipt va oY Odo.
to qe nerate YMdom no. amd c ce
W Cod
var mn: matn.Yandon C)
if (n.2 o)
docu ment.write( evan'");
else P
dlocu ment. write("odd;
S
b
fu
Numbe in javasept me in dloubleporeain b4 bita format
VCodE Snippet to die play ignet numbc tom umg,Am2
num , nm
num4);
x= matth.max(num1,num2,num3,
document write( "Hignut valne: +)j
nuhbes
not nawe speei
Vaid jowassapt VaiabesOshoud
) oud mt hawe al charaters
sthould not be some as predefind thing
Ue funchion, Na N ete.
tXptaiM: 9. Event Handles: H a comnmd tht is wsed to
to
speeify aetion in Yespo ne
event. Onload, On Mouseover.Oneick
2. Objets: Objets ae cole ctios o name-vaue pauTS,
The name pat is a jowasenipt string wie vaue com be ete.
Vaue o amothe obfect. Mata olbject, shing objeut.
3.0peYators : Thex ae bols which peform some operation
On Vaues. Avi thmetie peatm, lagieal operatrv

Anonymaus Function : Funetins ielh do not hawe an name


V
funetono
for (osio,je arquments.lengthi i<j. it)
3
3
return sum/ argumont. ung
W Codus to
prin string mppe cae %.to Upper cam()
rit fi7st 2 chanactes n
7eN the
sur stbing(o,2)
sfring
DOM: Doeument Object Madel k
betw een
Subskring : tuwo
Exhaci the chanacteu fom the soring
tor speeif'ed indie.
2. Concat (): t no or more omd retwm a copy f the jrinds
stings.
3. Stitt () : Rmove tue firt elemet of on nay amd vetat
twmch'm geatut (ng ,n,n3)
(nsn)
it (n1n3)
Ant ('quatet no a' +n1);
+
doumnt. write ("guatet o.un3);
doument. write ("gaest no. utn2);
dowmnt. write ('guatut no. u"tn3)>
dasplay no. ot
nanm from wser
WCode to aeeeptiv name amd lost cent date, ms namne mha
chanactens i first name,o play (KYisham Kumanyolo
latten of st nam Od conpete tast ham
skpBay kKnman)
(snipt
Vav F prompt ( "ente first name")
last name ;
Va I rompt ('enter
d hw Date ();
Va
write ("todw's date (s"+d))
dou ment. name is'f.ungta)
douume ntt.write("ungtn of f'st
{[o]+"," ))
doumnt.write("you name i +
<Isipt>

sondg
<suipts
var dow : C"Monday 'Sunday'
vaY n - Math. andom l dow)
doumnt.write (n);

WCod to aceept aghing from wer omd duply the first ocEMCe
of the ovda
<htrms
<body>
<suipts
var str prornpt ("nin a sting " i
docurnant. write (str matehl"gouda")
doenmant. write ( str. Inde xop ("qood)2)
</seript <(bocy /htme
PYediet he output <seipt >
n= 20

X= n<<
doumemnt. write ("vauu aften right slfti" +m)
doument.write ( "vae atteu wtt uft +}
</saipt> (n+2)+ 2
Vau
n<s 2 meoms n X2x2

tht tollat omd snmdust heigut af student


<seuipts
Var i= 0;
str
Var Stt ewArYay ()i
¿stri] rompt ("enter higut"
itt)
mamgs the string 'str' in ucending ovdr
sly. sort(0;
document,write ("s walest", str [o]);
oou me nt. write (" Tauest "" st [4D)
</septs
Pop() mthod Th popl) mtnood ia similas tb the sift () method
The sifmethod emoves the fist ee ment o the
omd pop() method vemoves kat ellment ot ivn amg
cq: ceoth> ["hirt", "Pot', "TSit";
Cbth. pop)) now cloth iu beeome ("Stirt", Pant]
pop() :Yemove lat ee mert of Functi
ons
* pushl): in seuts amay
nw element at end
asoiated
with
stacu.
Shil : vemoveu fivst eement ot amay
unchitt) int neweument at
wCada to ds
plouyia vaniat& Salay of ofvame 1000o00 mo
(scuipt>
Var
YaY bo nws L000000
Salayoros;
document.write(salayt bona)) his
fpuie fappe Mangoes" orarge
Levite commamda in jawasipt ta in the last
add am itam Cuava" to t e aMa

oploy no puits
i add folcouin aay to am a
a (° Potato", "Brinjal' aurd"])
Ams user: is fuits push ('auovo')
(ö)fuits. shift ()
io documant.urite (fpuits.ungi);
(iv) fuits. concat (veg)i
wDetlane a fnetion stoingsimjavo to aceept two sting arqenrs.
The functicn snod
9conNet botth strings to ppenca
Kancin for shingi omd shing2 omd display 1uifoun
th
Q) loe au oceences of aue 'A' in sfing1
Ew Display irst cnaracter of stri ng2.
Aswer: function stringsin jova (s1, s2)
s1. to Upper casel))
S2. to Upper
caxl);
dounent.write ( s2.matc (Sa))
dowment. write(s1. Yeploe ("A', *))
doument. write (s2 -substring (o));
3
| . Tw0 oys to cowet numbr to
unay t operatr (concalenatin)
A ohat do
by mopekus amd mnodA f am objeut?
repeatie : dfine th ciarateniitiu of om
Methods: aue te actions ttnat con be objet. eg: otor, Umgthete
alert, confirm ete petormed on the obet. g
’ Afntian
or Ateted functian
deelared
net ed function. iide amother fmctin ç caled tnner or
e: function abe C)
YuttmatL, vow a 1

fun tion abcdC)


Vetwn at1
e PvedE ne utput <seipt >
h= 20
m= n> 2
x = n <<2
tm)
do umemt. write (" vae atte rigntsiftie"+)}
doume nt.write ( "va atteu tt s f
WCode to accept 3 numbes amd ftnd
<supts
prompt ('Nm")
Vony pro mpt ("Num")
von 2 =prompt ("Num3")
average (xtyt2)/3
doument.wrie
</suipt >
("awuagis"t oweage)
ips to nemembe shen witing jowaesipt:
J. Jowa suipt u case sensitive
2. Blons spaces between wdA ne ignored.
3. JaNaseipt codu end ui ta a Semiolon (;).
Q. Predit the outputs: Opare Int ( "io", 2) = 0's
2) Parse Tnt ("lO1", &) = 6S
Parse Int( "lol", 10) 101
1.Write a code in JavaScript that accepts a binary number from the user and
displays its decimal equivalent number.
Answer:
<HTML>
<head>
< title>Binary to Decimal ‹/title>
</head> ‹body>
<script type="text/javascript">
var binary = prompt("Enter a binary number ");
var decimal = parselnt(binary, 2);
document.write("Binary Number: "+ binary + "<br>");
document.write("Decimal Number: "+ decimal + "<br>");
</script>
</body>
</html>
Output: Binary Number: 101001 Decimal Number: 41
2. Write a code in JavaScript to accept five numbers from user, store them in an
array, and display the sorted array.
Answer:
<script type="text/javascript">
var num = new Array(5);
for(var i = 0; i < 5; i++)
x = parselnt(prompt("Number "+(i+1)));
num[i] = x
}
num.sort:
document.write("Sorted Array" + "<br>");
for(var i = 0; i < 5; i++)
{
Document.write(num[i] );
</script>
OUTPUT:
Sorted array
34678
3. Write a code in JavaScript to accept a number from the user and generate
(a) a random number greater than the number entered.
(b) next even number after the number entered
Answer:
<script type="text/javascript">
x = parselnt(prompt("Enter a Number "):
var num = Math.round(x + Math.random * x)
document.write("Random Number greater than" + x + " is" + num + "<br>");
var even = 0;
if (x % 2 == 0)
even = x + 2;
else
even = x + 1
document.write("Next Even Number, after" +x + " is "+ even + "<br>")
</script>
4. Write a program in JavaScript to accept marks in three subjects, display the
total marks obtained, the percentage, and the grade as per the norms given
below:
Percentage Grade
>= 75 A
< 75 and >= 60 B
< 60 and >= 33 C
< 33 D
ANSWER:
<script type="text/javascript">
x = parselnt(prompt("Marks 1 ")):
y = parselnt(prompt("Marks 2 ")):
z = parselnt(prompt("Marks 3 ")):
total = x + y + z;
percentage = total / 300 * 100:
document.write("Marks 1:" +x + "<br>"):
document.write("Marks 2: " +y + "<br>");
document.write("Marks 3: " +z + "<br>");
document.write ("Total Marks :"+total+ "<br>");
document.write("Percentage:" +Math.round(percentage)+"%"+ "<be>");
var grade=* ":
if (percentage >=75)
grade = "A";
else if (percentage >= 60 && percentage < 75)
grade = "B";
else if (percentage >= 33 && percentage < 60)
grade = "C":
else
grade = "D":
document.write("Grade :" + grade + "<br>");
</script>
5.Predict the output of the following:
<html>
<body>
< script>
var fruits = ["Apple", "mango"];
fruits[50]= "Orange";
document.write(fruits.length);
document.write("<br> end of program");
</script>
</body>
</html>
Answer: Output is
51
6. Rewrite the following using switch case statement:
if(a==1)
else if(a==2)
document.write("Monday, Wednesday, Friday");
document.write("Tuesday, Thursday, Saturday"):
else
document.write("Sunday")
Answer:
switch(a)
{
case 1:
document.write("Monday, Wednesday, Friday"):
break;
case 2:
document.write("Tuesday, Thursday, Saturday"):
break;
default:
document.write("Sunday")
break;
}
MOVLE EDITTING ToOLS

4. Diffuntiatu between soryboand weew nd timine ui:


defauttvilwhauie malu
windous Timetie
of
* Uscd to loolk at the scqueme Uud to adint dmation
{ clips iu ow projct ond taomition betwecn lips,
Ond vie the amio track.
7caMongi tiam
y uideo affecti Proidu a more detaied
Lets ws see
or tromitin tiat hawe bien ai evo of oe movie proteela
added. and alos ws to makefiva
edits .

Audio cip ane not

2- DiffuuNe betwcen nd toim clis.


3. Steps to noo a tim med clip in vindos Novie Maller :
’ wiu on timeline viw
’ Ciek on the trimmed ip ’ cipk cip cicu cleu checepoine.
THREE PANE S OF WINDOS MOVIE MAKEK:
com mon tasks that ane neLdid to male a
" TAk Pane: lists the
movie.
cowction folds, which contoi clips.
"Collectons Pane:
. Contlnt
displays
Pane: slows tis,cfeca or traitions we ae worwing
with.
S.Plas to add tite text A a moviel:
Oat the
before or atte acip
G. Non- dtstrctiva, Non-Line toos !
a. 2wei- Steim b. AVITn'us vida o editor

7.WAX Com work in 2 modesi :


(iy as a stondaone
G) as apugin to iappication
(fuo btginnes)
other vi oleo edito(tor profuiona)
Customising and Embdding

1.4 Advawtagas d usingi mutiwedia on a weopage:viewes.


Greatu immerion: ulti dna ale atrat
> Ennomce d sEO Yankings: multi medla fileu inar sEO ronaings.
> BeHe Branding: mutimedia site aie frequemty rfteed by
mal ing depantmemta
(
2. Tia Typs of images: I. Rante 2. Veetoy.

Composd f afeld Uated drening


wt mad
ewid by a cotor. bat objec
3. gif:-Stomda for arapliu 2utenchomge for mat
"Cneo de d , 256 color (8 bit) imags.

4.
Lossy Lossess
Vthey ose YUomtion (shaupnen) Vloslem do ot Looe my
whn coweted to oten
formatu informaton
eq: JPEG
S. FouY Search Engine
components :
Page tite (ony tist 70 charatem)
" Page Des ouiplion ( fist Is6 chaacteus)
"Page heywDrdh
"
ines to
othepages
6. Statie webpagu: bane
websites, elements on't
(HTML,PHP) Umil amd nnles oou- end code u chomge
pdoted!
Dynommiecepagesi
(ASP, PHe) Wepage ele memla heep wpdatiug
time.
feate: wed to Karch ino, submit orms
IS
Tutnet Tuformation Suwicer
Memoin extemion o audio, video.image fies
Souna fitese files containing data in audio format.
Sovage: the a digital
of sownd objects wd in th compoitin
natile Unloddimg sOndf s
)Dont vaudate webpag
tag
additiona atrìbutes
Check out emhed teg for
Embedding Video :
OYoutube Embed code: can be copied and psted
) Vidu o mbd cod
(3) fae book udeo
eo inteqration
(9 HTML S ideo
0Embed

i) Tmetiu flas into a deomaoNe pagei witin


dreomuewu, pul doun the insut mend amd select media
tuen scet Fla.
à) <objet>,<embtds
)using owaseai pt .
MUltimtdia Mtimdia i the media that es mutipe
form of eond ent (eg text, audio, vido, pictue
to inform and ant ertain we
IEmbedding *< BuSound >taq ony worWs in
Yeader MP3 player intenet Explorer (IE).
O Yanoo media ploy
DMixpod.
Embed Taq: Cm be wcd to adding a bmdio r video fe in a

atributes f embed tag:0sre (stonols for sDnee)


OLoop "bue" or Loop :"fou
Auteplay fase
* Short notes: MIDI, Plug- In, Helper appicati ons, Mix lod, ete
Alvancad Eatures

Snippet: piees of codes nioh ane re - wd by devlopes


These oe ycom be Npeatedy md they
Sowe a ot tim.
PSD: sfamdu for hotosrop Do cmmunt. Contents o tpagcs
Somatinies cMated 'wmng Adobe Photoshop to maue them
more attrative.

DWI: Sfomds for Dynomie Web Temmplate


o. of
vocbpages iniu a wtbite
n al
eg: On o m website, some common itums may be

ago, copgYiqht ete. bt the contut may vay


far
poge. Hee te com s DNI h male fxed ponions
Conmon ela ments md chomgabe port ons on eaca
by
Add- Ins these Coddes exBnd the
emhocad
capobility 4 maim
stom com mamdu and ae
featmes. addiug
ww. weba ist. cOm, www. dotneteu rr com.

iCoae-Optimikation: be fove publising a websiu, we need to claom up


coddu that will
oww we bpoge tor omy wnneessay
incease ow page sige for no Oson.
Wab Hottng: when we uwamt othns to see om content in a webn te,
we need to hot tue contunt in a webswer to be
viewed by publie
SEON Search Engine optiis ation refes to the proces that ateeta
the iebsite viibiy Yomking when oii plagig Kancla
Yeuts.

(8srCmcading Stye Sheeto oetmplateu that com be und to desigu


Ow webites.

Memori web tools: Dreamweave, Kompo2er, lte


authoring
SEO Cu clesy: I ù atopl that StOMs o y metb page to techmeal
evoss ond sE0 wsns that com howe am impact
on Kanch engivt 7omling. Seanch engins
odbsitea that affe free css temmplateg:
spiders
2. www. Hempatemo, Com Memon ise
3. www. oSwd.
ATa verity and fix ervovs bcfove pub lithing aa websitey
select too u> Recalate hmypelinke
AAdiaj box wil appea
(3ice yes.
thee ae my , it wi be fixed automatieally
Intetisense Iuteli scnu u aa featme that antomati cay provid
you wita a histo t cooes nd atri butes as a pop-p
shen you w
work ia the co dde vier modde
Mod
SFTP
used by Weskostiug povious to upload a website:
’webDAV
*Nab Pacuage i It is a featme to tramwfe contenta ot ow entire
webite'to a emote compute

You might also like