0% found this document useful (0 votes)
12 views5 pages

Replict

The document contains JavaScript code snippets demonstrating various programming concepts such as variables, functions, arrays, objects, loops, and methods. It includes examples of basic operations, conditional statements, and dynamic function definitions, as well as array manipulation techniques like map and filter. Additionally, it showcases how to work with user input and display results in the console or through alerts.

Uploaded by

r00642853
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

Replict

The document contains JavaScript code snippets demonstrating various programming concepts such as variables, functions, arrays, objects, loops, and methods. It includes examples of basic operations, conditional statements, and dynamic function definitions, as well as array manipulation techniques like map and filter. Additionally, it showcases how to work with user input and display results in the console or through alerts.

Uploaded by

r00642853
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

// console.

log('hello world')
// console.log('anurag raghav')

// // variables
// Name = 'anurag'
// console.log(Name)
// //operators
// food = 100
// console.log(food)

// food = 400
// tippercentage = 0.5
// tipamount = food * tippercentage
// console.log(tipamount)

// food = Number(prompt('amount of food eaten?'))


// tipgiven = Number(prompt('percentage of tip given?'))
// tipamount=food*tipgiven/100
// total=tipamount+food
// console.log('total-',total)

// exponents// console.log(2**10)
// modulo or remainder \
// console.log(5%2)

// baby weather app

// let weather=prompt('how is the weather?')


// if(weather=='rain'){
// console.log('grab your umbrella')
// alert('grab your umbrella')
// }
// else{
// console.log('wear your sunglasses')
// alert('wear your sunglasses')
// }

// function saymyname(){
// console.log('anurag')
// }
// saymyname()

// // dyaniamic fuctions
// function saymyname(name){
// console.log(name)
// }
// saymyname('raghav')

// // arrow functions
// let saymyname=(name)=>{
// console.log(name)
// }
// saymyname('anu')

// // templet letrals
// let saymyname=(name)=>{
// console.log(`Hii,${name} how are you?`)
// }
// saymyname('anudhi')
// let sum=(a,b)=>{
// console.log(a*b)
// }
// sum(10,5)

// return use
// let sum2=(a,b,c)=>{
// return a * b + c
// }
// console.log(sum2(10,7,9))

// // arrays
// const groceries=['apple','banana','mango','oranges']
// console.log(groceries)
// // console.log(groceries[0])
// groceries.push('pear','blueberry')
// console.log(groceries.slice(1,5))
// console.log(groceries.indexOf('pear'))
// console.log(groceries.length)

// objects{}

// const person={
// name:'anurag',
// height:'6feet'
// }
// console.log(person.name)
// console.log(person.height)

// const human={
// name:'raghav',
// height:'6feet'
// }
// // example of dot notation
// console.log(human.name)
// // example of bracket notation
// console.log(human['height'])

// // assign things
// human.phone='7833687368976'
// console.log(human.phone)

// console.log(human)

// const boy={
// name:'anurag',
// studing:'mca',
// age:'22',
// skintone:'bright'
// }
// console.log(boy)

// // object inside of a function


// const introducer=(Name,shirt)=>{
// const person={
// Name:Name,
// shirt:shirt
// }
// const intro=`hi my ${person.Name} and the color of the shirt is $
{person.shirt}`
// return intro
// }
// console.log(introducer('anurag','black'))

// const introduction=(Name,Shirt)=>{
// const person={
// Name:Name,
// Shirt:Shirt
// }
// const intro=`Hi my ${person.Name} and my ${person.Shirt}`
// return intro
// }
// console.log(introduction('Anurag','black'))

// const
groceries=['apple','banana','mango','oranges','apple','banana','mango','oranges','a
pple','banana','mango','oranges','apple','banana','mango','oranges','apple','banana
','mango','oranges']

// // loops
// for(const grocerie of groceries){
// console.log(grocerie)
// }

// const number=[1,2,3,4,5,6,7,8,9,10]
// let result=[]
// for(const anu of number){
// // console.log(anu*2)
// result.push(anu*2)
// }
// console.log(result)

// const lettercounter=()=>{
// const phrase=prompt('hey,can you tell me what happend that night?')
// for(const anu in phrase){
// console.log(Number(anu)+1)
// }
// }
// console.log(lettercounter('phrase'))

// const sumarray=()=>{
// let result=0;
// const array=[1,2,3,4,5,6,7,8,9,10]
// for(const anu of array){
// console.log(anu)
// result=result+anu
// }
// return { result }
// }
// console.log(sumarray('array'))

// const max=()=>{
// const array=[1,2,3,4,5,6,7,8,89]
// let result=array[0];
// for(const anu of array){
// if(anu>result){
// result=anu
// }
// }
// return result;
// }
// console.log(max('array'))

// const letterfrequency=(phrase)=> {
// console.log(phrase)
// let frequency={}
// for(const anu of phrase){
// if(anu in frequency ){
// // frequency[anu]=frequency[anu]+1
// // another way of writing this
// frequency[anu] += 1
// }
// else{
// frequency[anu]=1
// }
// }
// return frequency
// }
// console.log(letterfrequency('anurag'))

// inrements opeartors
// ++ -- +=

// const wordfrequency=(phrase)=>{
// let frequency={}
// for(const anu of phrase){
// console.log(anu)
// if(anu in frequency){
// frequency[anu]+=1
// }
// else{
// frequency+=1
// }
// }
// return frequency
// }
// console.log(wordfrequency('lol what lol'))

// array methods
// 1) map
// const doublenumber=(number)=>{
// return number.map(number=>number*2)
// }
// console.log(doublenumber([1,2,3,4,5,6]))

// 2) filter
// const filter=(number,greaterthan)=>{
// return number.filter(number=>number>greaterthan)
// }
// console.log(filter([1,2,3,4,5,6,7],3))

// not working 3hr 20min video


// const actors=[
// {name:'anurag',netWorth:1000000},
// {name:'raghav',netWorht:2000000},
// {name:'anu',netWorth:1000},
// ]
// let result=actors.filter(actor=>actor.netWorth>1000)
// console.log(result)
// result.map(actors=>actors.name)

// // playground.innerHTML='<h1>anurag</h1>'
// playground.innerHTML=`<h1>${(result[1].name)}</h1>`

// reduce

You might also like