JS – Shuffle Card – DOM Object

Shuffle the cards below:

JS – DOM Object

Enter your car details below:

Shopping List

Get it done today

  • Notebook
  • Jello
  • Spinach
  • Rice
  • Birthday Cake
  • Candles

Source Code

JS: Loops

  • for
  • forEach
  • map needs return

Objects

  • for of : for(item of Object){}
  • for in

 

  • Object.values need foreach or map and output will be only the value
  • Object.entries need foreach or map and output will be key + value one by one (good for replacing keys)

PHP -> Object – Class – Method

Enter your car details below:

Source Code

class Car{

/* public $carname;
public $year;
public $model;*/

public function __construct() {
$this->carname = $_POST[‘carname’];
$this->year = $_POST[‘year’];
$this->model = $_POST[‘model’];

}
function Showall(){
echo $this->year.” “;
echo $this->carname.” “;
echo $this->model.” “;
}

}

}

?>

<form method=”post” action=”6.php”>
<input id=”year” name=”year” placeholder=”Year”></input>
<input id=”carname” name=”carname” placeholder=”Brand”></input>
<input id=”color” name=”model” placeholder=”Model”></input>

<button id=”btn”>go</button>
</form>

<?php echo “<br>Hello, I have a “;
$goodcar= new Car;
$goodcar->Showall();
?>

JS – Object – Class – Method

Enter your car details below:

Source Code

<input id=”year” placeholder=”Year”></input>
<input id=”brand” placeholder=”Brand”></input>
<input id=”model” placeholder=”Model”></input>
<button id=”btn”>go</button>


<p id=”demo”></p>

<script>

var year= document.getElementById(“year”);
var brand= document.getElementById(“brand”);
var model= document.getElementById(“model”);
var btn= document.getElementById(“btn”);

btn.addEventListener(“click”,function(){

class Car {
constructor(year,brand,model) {
this.year = year;
this.brand = brand;
this.model = model;

}


present(x) {
return x + “, I have a ” + this.year+ ” ” + this.brand+ ” ” + this.model;
}
}

mycar = new Car(year.value, brand.value,model.value);


document.getElementById(“demo”).innerHTML = mycar.present(“Hello”);
})
</script>